Re: Shutting down thread with Socket blocking for connection

2012-03-15 Thread Danny Arends
You could have a look at my attempt: https://github.com/DannyArends/D-coding/tree/master/src/web

Re: Shutting down thread with Socket blocking for connection

2012-03-06 Thread Vidar Wahlberg
On 2012-03-05 09:38, Dmitry Olshansky wrote: ... while(working){ if(select(set, null, null, 10) 0){ //10 usec wait on a socket, may do plain 0 sock.accept(); // no blocking here } set.reset(); set.add(sock); receiveTimeout(dur!us(1), (int code){ working = false; }); } ... Thanks for the

Re: Shutting down thread with Socket blocking for connection

2012-03-05 Thread Dmitry Olshansky
On 05.03.2012 1:46, Vidar Wahlberg wrote: Coming from a C++/Java world I find D's approach to concurrency slightly difficult to grasp, perhaps someone could help me out a bit on this problem: I'd like to have a method that spawns a new thread which sets up a socket and listens for

Re: Shutting down thread with Socket blocking for connection

2012-03-05 Thread Regan Heath
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

Re: Shutting down thread with Socket blocking for connection

2012-03-05 Thread Dmitry Olshansky
On 05.03.2012 16:46, Regan Heath wrote: 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.

Shutting down thread with Socket blocking for connection

2012-03-04 Thread Vidar Wahlberg
Coming from a C++/Java world I find D's approach to concurrency slightly difficult to grasp, perhaps someone could help me out a bit on this problem: I'd like to have a method that spawns a new thread which sets up a socket and listens for connections (in a blocking fashion). This part is