threads: Waiting for event & shutdown socket
Benjamin Schulte
Aldoric at gmx.de
Wed May 30 15:14:58 PDT 2007
Well, for question 1: I want to have the thread to be paused until I set a variable to TRUE (for example). Don't exactly know how the SleepEx method should work. And as soon as I use winAPI methods, I also could use WaitForSingleObject.
Question 2:
I have the methods:
startServer( )
which creates a thread that runs the server and handles everything there.
closeServer( )
this should KILL the thread. Wherever it is at the moment.
the thread itself just has a structure like (it's a one-client-server, cause I never would need more in this case):
- create socket
- bind socket and listen
while( true )
{
- accept
- handle messages
}
And for the case, no user connected to the server it will block at "accept". When I call 'closeServer' it should close the thread, even if it's in the accept method.
Hopefully I was able to explain it a bit exactlier now. I know, I have a bad english ;)
More information about the Digitalmars-d
mailing list