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.Originally Posted by Eibro
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.Originally Posted by Eibro
Eh? His would require another thread to set the quit event.Originally Posted by master5001
Right, but what if you don't want to close the socket?
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
Why else would you want accept() to die? That socket is typically used for nothing more than accepting clients.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.
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
*cough* non-blocking functions *cough*
That's what anonytmouse did. Anyway, select() works wonders too.
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
What do you suggest? Setting a socket to non-blocking mode and spinning the CPU until you can accept a connection?Originally Posted by master5001
No, anonytmouse's method blocks perfectly well.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().
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
AcceptEx please
Ahh.. right, overlapped completion routines.
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
Preferably not completion routines, completion ports.
I thought IOCP only works on certain OS'es?
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
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.