Unblock a Blocked Winsock accept() Call
Solution 1:
One way to unblock a blocking accept()
is to close the listening socket from another thread. Otherwise, you can put the listening socket into non-blocking mode and use select()
(which does support a timeout) to detect when accept()
can be called without blocking.
Solution 2:
A robust way to unblock the accept() call from another thread is to create a connection by using connect(). Of course, the thread needs to know what IP address and port is being listened.