Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost::Asio - blocking read on socket does not disconnect when socket closed from other thread
From: Nick Aschberger (nick.aschberger_at_[hidden])
Date: 2010-01-25 17:43:13


Igor R wrote:
I would expect the worker thread to return from the blocking
boost::asio::read
call, with an error.
This occurs on windows, but does not happen on the linux build of my app -
it never returns from the above call.

Why does the second thread never return? What am I doing wrong?
    

Socket object is not threadsafe -- it's not safe to access it from
multiple threads.
  
I was under the impression that it was threadsafe.

The only other option I have then is to allow the socket read to time out.
Why is it that boost::asio::read does not timeout with "SO_RCVTIMEO" or
similar, as per normal posix sockets?
Is there a way to get this to happen - ie have the read time out with an
appropriate error?

Example code I have seen for timeouts seems to be a lot more complicated
than what would be done in posix, ie:
http://bicosyes.com/boostasio-synchronous-read-with-timeout/

Surely there is a simpler way?

cheers

Nick


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