Can a bind of a socket be unbound due to network/stack activities?

I apologize if this question has been asked and answered, I found it difficult to come up with search terms for this question.

I’m using nonblocking sockets, but to simplify things, in this question, I’ll use blocking sockets.

Given a socket that has been successfully bound, e.g. by the following code

#include “mbed.h”
#include “EthernetInterface.h”
#include “TCPSocket.h”

int main()
EthernetInterface eth;
nsapi_error_t error;

TCPSocket server;;
server.bind(eth.get_ip_address(), 23);

auto socket = server.accept(&error);
if (socket) { socket->close(); }

My question: Is it possible for the bind to be broken without calling ##server.close()##? Is there an error code returned in ##error## that I should pay attention to that would require me to clean up and create a new server socket to re-establish the bind?

Thank you.


If something happened in the connection the TCPSocket will return negative value and yes the bind can be broken without calling server.close().
If the socket bind is broken the application should close() it and open it again.


Thank you.

Would all such errors signal via the handler attached via the sigio() call? Or do I need to periodically check the server socket for “aliveness”?