Shutting down thread with Socket blocking for connection
Regan Heath
regan at netmail.co.nz
Mon Mar 5 04:46:18 PST 2012
A more efficient approach is to use async socket routines and an event
object.
So, in main you create a shared event object, then start the listen thread.
In listen you call an async select or accept, and then wait on that /and/
the shared event object.
To stop listen you set the shared event, which wakes it, and it notices
the event is set and performs the cleanup/stops itself.
I'm not sure if phobos has support for this sort of thing yet, but you
could always leverage the underlying C library. I may be able to offer
some pointers on Windows, but I haven't done something like this on any
unix platform for a while..
Regan
More information about the Digitalmars-d-learn
mailing list