Note that there are some explanatory texts on larger screens.

plurals
  1. POBoost asio-acceptor unblocks without a new connection?
    primarykey
    data
    text
    <p>I am using the C++ boost asio library, where I listen to new connections on the socket. On getting a connection I process the request and then listen for a new connection on another socket in a loop.</p> <pre><code>while (true) { tcp::socket soc(this-&gt;blitzIOService); this-&gt;blitzAcceptor.listen(); boost::system::error_code ec; this-&gt;blitzAcceptor.accept(soc,ec); if (ec) { // Some error occured cerr &lt;&lt; "Error Value: " &lt;&lt; ec.value() &lt;&lt; endl; cerr &lt;&lt; "Error Message: " &lt;&lt; ec.message() &lt;&lt; endl; soc.close(); break; } else { this-&gt;HandleRequest(soc); soc.shutdown(tcp::socket::shutdown_both); soc.close(); } } </code></pre> <p>According to my understanding it should always block at <strong>this->blitzAcceptor.accept(soc,ec);</strong> and everytime a new connection is made it should handle it in <strong>this->HandleRequest(soc);</strong> and again block at <strong>this->blitzAcceptor.accept(soc,ec);</strong></p> <p>But what I see is this that for the first time it will block at <strong>this->blitzAcceptor.accept(soc,ec)</strong> and when a new connection is made it will handle the request, but instead of blocking again at <strong>this->blitzAcceptor.accept(soc,ec)</strong> it will go ahead into <strong>this->HandleRequest(soc);</strong> and block at <strong>soc.receive();</strong> inside.</p> <p>This doesn't happen always, but happens most of the time. What could be the reason to this behavior, and how can I ensure that it always block at this->blitzAcceptor.accept(soc,ec) until a new request is made?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload