I am using Winsock under VS 2008.
I have a thread dedicated to accepting incoming TCP connection requests via a blocking call to accept(). When the time comes for my app to shut down, I need to somehow unblock this thread so it can perform its shutdown work and exit. Is there a way I may unblock accept()?
I will post another question in case there is no way to unblock accept(). That question is: If I perform a hard kill of the thread that is blocked on accept(), will anything bad happen (corruption of OS data structures, etc.)?
Thanks,
Dave
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 useselect()(which does support a timeout) to detect whenaccept()can be called without blocking.