Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
4 years, 5 months ago.
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
Binding a socket
#include "mbed.h" #include "EthernetInterface.h" #include "TCPSocket.h" int main() { EthernetInterface eth; nsapi_error_t error; eth.connect(); TCPSocket server; server.open(ð); server.bind(eth.get_ip_address(), 23); server.listen(1); while(1) { 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.