2- Since I want to "netconn_accept()" call to be blocking, I did this, where pNetConnListener is a struct netconn*:
// Put a timeout of 0 to force a blocking accept.
pNetConnListener->recv_timeout = 0;
pNetConnListenerNewConn = netconn_accept(pNetConnListener);
// Check for incoming frames.
pNetConnListenerNewConn->recv_timeout = receiveTimeoutInMs;
pNetBuffer = netconn_recv(pNetConnListenerNewConn);
if (pNetBuffer != NULL)
{
.......
}
else
{
// Detect if there was a problem or it's because there was no data.
if (pNetConnListenerNewConn->err == ERR_TIMEOUT)
{
// No data received. Since we should receive a keep alive packet every x seconds,
// this mean that the host has a problem or the connection has been broken
// (disconnected cable for example). Disconnect and prepare for next connection.
break;
}
else
{
// For any other errors, it's a problem. Disconnect and prepare for next connection.
//print_dbg("CommManager - ListenerTask Connection Problem.\n\r");
break;
}
}
My search of LWIP_SO_RCVTIMEO indicated that it's not used anywhere else that needs attention (except for the netconn_accept()). So, now I can disconnect and reconnect my cable at will!
Hope this helps some others!