Winsock 2 - Closing App While Accept() Is Blocking?

Hey everyone :)

I have my accept call running in a while loop:

1
2
3
4
while(running)
{
...
}


This is in a thread. When I want to shut down the application I enter 'X' into the console. This sets running to false, then I close the socket and do the clean up. However I keep getting the good old windows error message pop-up which I can't understand at all. I'm pretty sure it is because accept is blocking and I'm closing the socket?

How can I cancel the accept call? There was a WSACancelBlockingCall function, but I can't use that in Winsock 2 - it is unsupported.

Any help would be awesome, Nick :)
Go to : http://tangentsoft.net/wskfaq/articles/lame-list.html

And look for : 9. Applications that don’t properly shut down when the user closes the main window while a blocking API is in progress. Totally lame.

It's "shutdown procedure" might prove helpful.

Topic archived. No new replies allowed.