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.

UDP Socket errors after disconnect and reconnect

Other Parts Discussed in Thread: CC3100

I am running a UDP server.  I open the UDP socket and bind the port.  Everything works fine.  Then, I force a disconnect+reconnect by disabling wifi on my router, then re-enabling it.  When the cc3100 reconnects to wifi, I call Socket Close for the sockets that must be re-established.  But when I call socket_close, I get the response code -8, which apparently is "socket command in execution".  Then when I try to open new sockets, I get higher socket IDs and the Bind to the ports (which I was previously using) now fails with error -98, which is "Address already in use". 

It appears that if you have a wifi disconnect while sockets are open, those sockets become orphaned.  Like zombie sockets that cannot be closed. 

Anyone else encounter this? 

Or has anyone recovered from a disconnect with no problem?  If so, can you tell me (at a high level) what steps you took? 

I was thinking that maybe the cc3100 automatically closes all sockets once it gets disconnected, but if that were true, I would expect a different error code and I would expect the socket IDs to be reused when I open new sockets.  Both the error codes and the high socket ID indicate that the socket is not closed after the disconnect+reconnect.  And the close fails, so I am not sure what to do. 

-Valkyrie-MT

P.S. This happens on the current v1.0 firmware (as well as the previous version)

  • Hi Valkyrie,

    I just tried this:

    1. Connect to AP
    2. Start UDP server "A" and bind to port 3333
    3. Restart AP
    4. Connect to AP
    5. Close "A"
    6. Start UDP server "B" and bind to port 3333

    All of these things go through as expected.

    So at least at this basic level, I don't see an issue. I'm using SDK 1.0 btw. Perhaps the issue arises when some other stuff is added. Perhaps you could reduce it down to what I did and see if you still have the issue? Then maybe by slowly adding more of your program back in we could figure out what does it...

    Thanks,

    Aaron

  • Thanks a lot Aaron.  I really appreciate you validating that it does work fine.  I will start with reproducing your steps and as you suggest, work my features back in to see what I am doing to cause this. 

    I'll reply back here when I have more information. 

  • I have a similar issue: bind to a local udp port, then call blocking recvfrom on it.

    if I try to close the socket and re-open it, binding succeeds (no "address in use" error), but when calling again recvfrom I get a -8 error. cant find a way to "restart" the socket.