• AVR Freaks

Hot!Problems opening TCPIP client socket

Author
Rafauy
Starting Member
  • Total Posts : 60
  • Reward points : 0
  • Joined: 2015/07/16 10:38:53
  • Location: 0
  • Status: offline
2019/02/04 09:02:48 (permalink)
0

Problems opening TCPIP client socket

Hi,
 
I have some issues while trying to open a TCPIP client socket using Harmony stack. If I connect my board straight to my PC ethernet port, where I am running a TCP server (Hercules), it works perfectly. Always connects without delay. On the other hand If I put a switch (Cisco SG200-50FP) in between the board and the PC, things get weird. I place the open socket request and wait for the connection to establish, it  seldom connects at once. What I have is a five seconds timeout, If TCPIP_TCP_IsConnected doesnt return true withing this time I do a TCPIP_TCP_Abort and try again, sometimes it takes two or three retries and up to 20 retries in a few cases. I have tried increasing all the timeouts and retry attempts in the TCPIP MHC configuration but nothing seems to help. I am sure its not a parameter problem (wrong IP, or port, or things like volatile socket handles).
Any ideas?
 
Program flow:
SYS_STATUS_READY == TCPIP_STACK_Status(sysObj.tcpip);
then
TCPIP_STACK_NumberOfNetworksGet() > 0 
then:
TCPIP_DHCP_Enable(TCPIP_STACK_IndexToNet(0));
TCPIP_STACK_NetIsLinked(TCPIP_STACK_IndexToNet(0)) == true
then
TCPIP_STACK_NetIsReady(TCPIP_STACK_IndexToNet(0)) == true
then
TCPIP_STACK_NetAddress(TCPIP_STACK_IndexToNet(0)) != 0
//---The above code always executes successfully in both situations, so I think its not a data link layer problem----
 
//---This is where things get tricky---------------------------------------------------------------------------------------------
TCPIP_TCP_ClientOpen(parameters....); --> Never had a problem with this, no Invalid socket response
if(TCPIP_TCP_IsConnected(socket handle) == true)
{
    //Socket established
}
else if((5 seconds timeout) == true)
{
    if(TCPIP_TCP_IsReady() == true)
    {
        //---This is just for checking, the tcp stack is always ready, I have also checked the net link status.
    }
    TCPIP_TCP_Abort(socket handle, true);
}
#1

2 Replies Related Threads

    rainad
    Moderator
    • Total Posts : 1155
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: Problems opening TCPIP client socket 2019/02/04 13:29:54 (permalink)
    0
    Probably you should enable portfast on the switch. You can do a quick test with a simpler switch or connecting directly to a router and notice the behavior.
     
     
    #2
    muellernick
    Super Member
    • Total Posts : 466
    • Reward points : 0
    • Joined: 2015/01/06 23:58:23
    • Location: Germany
    • Status: offline
    Re: Problems opening TCPIP client socket 2019/02/06 03:25:33 (permalink)
    0
    Is that an issue with the PoE?
    Could you switch PoE off on your switch?
     
    Nick
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5