Opened 6 years ago

#12925 new Bugs

boost::asio::ip::tcp::socket::async_read_some() changes socket to non-blocking

Reported by: yogevch@… Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.60.0 Severity: Problem
Keywords: async_read_some non-blocking Cc: yogevch@…

Description

I'm not sure if it's an issue or not, so I'll try to explain without lots of code examples:

I have a socket:

boost::asio::ip::tcp::socket sock(ioservice);
sock.open(boost::asio::ip::tcp::v4());

I've connected the socket to external application with a third party API, which is a blocking call (for a blocking socket):

third_party_connect(sock.native(), ip);

And waited for some data on this socket:

mSubSock.async_read_some(boost::asio::null_buffers(), std::bind(&MyClass::OnData, this, std::placeholders::_1));

When MyClass::OnData got called, I've noticed that the socket turned to non blocking socket:

sock.native_non_blocking(); -> returns 'true'
anotherThirdPartyAPI(sub.native()); -> fails with EAGAIN because socket turned to non-blocking

Then another third party API call fails inside the MyClass::OnData function with errno: EAGAIN.

Is this the expected behaviour? why did my socket changed to non-blocking? (I've checked before the call to 'async_read_some' and it was blocking). I hope I was clear enough. Thanks

Change History (0)

Note: See TracTickets for help on using tickets.