AnsweredAssumed Answered

How do you detect (and handle!) a lwIP disconnection?

Question asked by dave408 on Mar 28, 2016
Latest reply on Oct 10, 2017 by Gustavo Costa

My application handles graceful closing of the socket, but it does not recognize when the Ethernet cable has been disconnected.

 

In my packet-handling loop, I check the result of all netconn commands used, which include:

netconn_recv

looping over netconn_data and netbuf_next to assemble a packet

netbuf_delete (no error check here, returns void)

netconn_write

 

When I remove the ethenet cable, the loop never exits like I would expect.  Outside the loop is where I call netconn_close and netconn_delete.  Because the loop doesn't exit, I cannot reconnect to my device after plugging the cable back in.

 

I can't get any MQX task data when I pause execution, but at one time I did see that the lwIP tcpip_task was blocked on a semaphore.

 

Can anyone suggest ways that I should be handling cable disconnections in lwIP?

Outcomes