Boost logo

Boost Users :

From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2005-10-04 10:00:22


lukas wrote:

>hi
>
>I'm new to boost.threads and have a basic question.
>During program execution the user has to check the connection
>to a server. This action should take place in a simple thread.
>
>
Do you mean that the program attempts to make a socket connection using
a new thread?

>If the user gets bored waiting for responce, he should be able to
>stop the process and return back to the main application.
>
>
How will the user interrupt?

>Is there a proper standard solution?
>
>
A common approach in POSIX would be to use non-blocking sockets and to
use the select() function to wait for a change of state on the socket(s)
or on standard input (or, in an X application, on the pipe or socket
used by Xlib). This way, there is no need to spawn a new thread per
connection (though it is useful to have another thread for doing name
lookups, because there is no standard API for running them asynchronously).

Under Windows you would probably use MsgWaitForMultipleObjects() or
asynchronous socket operations.

I'm afraid Boost.Thread doesn't cover these things, though asio
<http://asio.sourceforge.net/> and Giallo
<http://giallo.sourceforge.net/> attempt to.

Ben.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net