Boost C++ Libraries: Ticket #12437: asio::async_read with a tcp socket gives erroneous results under Windows https://svn.boost.org/trac10/ticket/12437 <p> I'm seeing asio::async_read give erroneous results with a tcp socket under Windows. </p> <p> From the asio source code, async_read under Windows calls WSARecv, and it directly violates the "specification" of that function. The line in error is in the function "start_receive_op" in the source file socket_ops.ipp. It reads: </p> <p> int result = ::WSARecv(impl.socket_, buffers, </p> <blockquote> <p> static_cast&lt;DWORD&gt;(buffer_count), &amp;bytes_transferred, &amp;recv_flags, op, 0); </p> </blockquote> <p> asio is using both the 3rd parameter lpNumberOfBytesRecvd which is set to "&amp;bytes_transferred" and the 5th parameter lpOverlapped which is set to "op". This violates the documentation for WSARecv. </p> <p> According to Microsoft's documentation for WSARecv's 3rd parameter lpNumberOfBytesRecvd: "Use NULL for this parameter if the lpOverlapped parameter is not NULL to avoid potentially erroneous results." Because the 5th parameter lpOverlapped is not NULL, the 3rd parameter lpNumberOfBytesRecvd must be set to NULL and bytes_transferred must be determined by some other method (probably by examining the contents of the lpOverlapped parameter). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12437 Trac 1.4.3 anonymous Mon, 05 Sep 2016 15:15:52 GMT <link>https://svn.boost.org/trac10/ticket/12437#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12437#comment:1</guid> <description> <p> It looks like the asio code is ok and this is an application bug. I attempted to close this ticket but couldn't find a way I can do that. </p> </description> <category>Ticket</category> </item> </channel> </rss>