This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

NDK socket not detecting cable disconnect

I have a socket open and communicating with a PC.  I disconnect the cable, I mean physically unplug it.  On the console I see this message:

Link Status: No Link on PHY 0

so, apparently the NDK stack 'knows' that the cable is disconnected.  The error returned by send() is  EWOULDBLOCK, indicating a timeout occurred.   Shouldn't it close the socket or return a "not connected" error?  The PC side is closing the connection, but mine never closes which is a problem.  I can't close the socket on a timeout, as these occur all the time (when the host has nothing to send).

C6748

BIOS 5.41.10.36

NDK 2.20.3.24

  • Hi Mary,

    I can see your rationale thinking with this. I think the "connected" state has a different meaning at the socket layer. Here, the socket has a logical link with other host, as opposed to having a physical link. I suppose, one could have multiple physical links, if one goes out, you could still maintain a logical one.

    Based off existing EMAC drivers, the physical link status needs to be determined by your EMAC driver. When the NDK polls _HwPktPoll, it checks for the link state and calls a EMAC_linkStatus() to notify the application of the physical lost link. You can use this to determine when the link got disconnected.

  • Thanks, that was very helpful.  I will check the linkStatus parameter to determine when the link gets disconnected.