Boost C++ Libraries: Ticket #13581: `basic_stream_socket::read_some` on `non_blocked` socket returns `ec=would_block` https://svn.boost.org/trac10/ticket/13581 <p> In the <code>boost\asio\detail\impl\socket_ops.ipp</code> file there is <code>sync_recv</code> function which should block until some data is received. </p> <p> Inside this function there is following <code>if</code> block </p> <pre class="wiki"> if ((state &amp; user_set_non_blocking) || (ec != boost::asio::error::would_block &amp;&amp; ec != boost::asio::error::try_again)) return 0; </pre><p> IMHO condition is wrong here. It should return 0 for all cases except socket is in <code>non_blocking</code> mode and ec is one of <code>[would_block, try_again]</code> </p> <p> In fact if socket is in 'non-blocked' mode and ec = would_block, it also returns 0. </p> <p> If assumption is correct, code should look like </p> <pre class="wiki"> if (0 == (state &amp; user_set_non_blocking) || (ec != boost::asio::error::would_block &amp;&amp; ec != boost::asio::error::try_again)) return 0; </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13581 Trac 1.4.3 Dmytro Ovdiienko <dmitriyovdienko@…> Wed, 30 May 2018 09:48:25 GMT <link>https://svn.boost.org/trac10/ticket/13581#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13581#comment:1</guid> <description> <p> Probably, I read documentation wrong. It should block in case of <code>blocked</code> socket. </p> </description> <category>Ticket</category> </item> </channel> </rss>