Hi, I've read the board and spent lots of time on this and I just can't work it out. How do I stop my server cleanly?

More specificially, with blocking sockets in a worker thread, once the socket is listening how can it be stopped (cleanly)? I've also had play around with WSAWaitForMultipleEvents, I thought that I could use WSASetEvent to get it to close - but I can only call this from within the thread, so I couldn't get it to work. Am I making sense?

So how is it done?!
Posted on 2004-04-09 12:16:09 by adamjjackson
or a harsh way
closesocket(), with this if you plan on restarting you have to remake the socket with socket()
Posted on 2004-04-12 11:30:06 by Qages
Posted on 2004-04-12 12:14:05 by f0dder
Hi, again I wasnt very clear, sorry. I know how to cleanly disconnect a client from my server, but I mean in the situation where my server is blocked and listening - there are no connections, how do I stop it listening and clean it up?

If I just terminate the thread then I don't get to clean up winsock...
Posted on 2004-04-12 15:59:15 by adamjjackson
Hmmm... you could use events for your network model, and include a "server is shutting down" even in the even array. Would limit you to handling, what, 31 clients per thread or so, but might work?
Posted on 2004-04-12 16:14:57 by f0dder