• AVR Freaks

Hot!Problems opening TCPIP client socket

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)

Problems opening TCPIP client socket

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);
TCPIP_STACK_NumberOfNetworksGet() > 0 
TCPIP_STACK_NetIsLinked(TCPIP_STACK_IndexToNet(0)) == true
TCPIP_STACK_NetIsReady(TCPIP_STACK_IndexToNet(0)) == true
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);

2 Replies Related Threads

    • Total Posts : 1202
    • 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)
    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.
    Super Member
    • Total Posts : 472
    • 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)
    Is that an issue with the PoE?
    Could you switch PoE off on your switch?
    Jump to:
    © 2019 APG vNext Commercial Version 4.5