Interrupting Socket connect()

View: New views
2 Messages — Rating Filter:   Alert me  

Interrupting Socket connect()

by Simon Reye-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If I have a socket like so:

boost::asio::ip::tcp::socket tcpSocket;

and call connect in a boost::thread like so:

tcpSocket.connect(endPoint, error);

It will 'hang' for up to 30 seconds if it can't immediately connect to the end point.

If I interrupt() and join() the boost thread it has to wait for the connect() call to finish.

Is there a way to cancel or interrupt the connect() call?

Thanks

Simon

_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Re: Interrupting Socket connect()

by Jonathan Franklin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Nov 1, 2009 at 11:31 PM, Simon Reye <simon.reye@...> wrote:
> Is there a way to cancel or interrupt the connect() call?

Set the socket to non-blocking, and then use poll/select.  Or just use
the ASIO async_connect mechanism.

Jon
_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users