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?!
Cheers
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?!
Cheers
shutdown()
or a harsh way
closesocket(), with this if you plan on restarting you have to remake the socket with socket()
or a harsh way
closesocket(), with this if you plan on restarting you have to remake the socket with socket()
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...
If I just terminate the thread then I don't get to clean up winsock...
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?