True, but anonytmouse's method looks pretty solid. Plus his method wouldn't require a worker thread to maintain which sockets need to be closed.Quote:
Originally Posted by Eibro
Printable View
True, but anonytmouse's method looks pretty solid. Plus his method wouldn't require a worker thread to maintain which sockets need to be closed.Quote:
Originally Posted by Eibro
Eh? His would require another thread to set the quit event.Quote:
Originally Posted by master5001
Right, but what if you don't want to close the socket? :)
Why else would you want accept() to die? That socket is typically used for nothing more than accepting clients.Quote:
Originally Posted by Hunter2
For the sake of pointless argument, I'll just say: Because perhaps you want to keep the socket bound on that port for later accept()ing ;) If you close the socket, there's a small chance that another socket will steal the port before you get around to re-binding to it.
*cough* non-blocking functions *cough*
That's what anonytmouse did. Anyway, select() works wonders too.
What do you suggest? Setting a socket to non-blocking mode and spinning the CPU until you can accept a connection?Quote:
Originally Posted by master5001
No, anonytmouse's method blocks perfectly well.Quote:
That's what anonytmouse did. Anyway, select() works wonders too.
>>Setting a socket to non-blocking mode and spinning the CPU until you can accept a connection?
Or you could have it in another thread, and then use anonytmouse's implementation - and if in your main thread you want it to abort the accept, you can cancel it by setting an event without closing the socket.
And as I have mentioned, though it means eating CPU cycles in many situations, you can emulate non-blocking using select().
AcceptEx please :p
Ahh.. right, overlapped completion routines.
Preferably not completion routines, completion ports.
I thought IOCP only works on certain OS'es?
Yeah, that's the limitation. NT,2k,XP,2003 only. But you'd mainly apply it to scalable servers (or clients), which personally I wouldn't bother running on 9x kernel machines.