Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes asynchronous receive guarantee the detection of connection failure?
    primarykey
    data
    text
    <p>From what I know, a blocking receive on a TCP socket does not always detect a connection error (due either to a network failure or to a remote-endpoint failure) by returning a <code>-1</code> value or raising an IO exception: sometimes it could just hang indefinitely.</p> <p>One way to manage this problem is to set a timeout for the blocking receive. In case an upper bound for the reception time is known, this bound could be set as timeout and the connection could be considered lost simply when the timeout expires; when such an upper bound is not known a priori, for example in a pub-sub system where a connection stays open to receive publications, the timeout to be set would be somewhat arbitrary but its expiration could trigger a ping/pong request to verify that the connection (and the endpoint too) is still up.</p> <p>I wonder whether the use of asynchronous receive also manages the problem of detecting a connection failure. In boost::asio I would call <code>socket::asynch_read_some()</code> registering an handler to be asynchronously called, while in java.nio I would configure the channel as non-blocking and register it to a selector with an <code>OP_READ</code> interest flag. I imagine that a correct connection-failure detection would mean that, in the first case the handler would be called with a non-0 error_code, while in the second case the selector would select the faulty channel but a subsequent <code>read()</code> on the channel would either return <code>-1</code> or throw an <code>IOException</code>.</p> <p>Is this behaviour guaranteed with asynchronous receive, or could there be scenarios where after a connection failure, for example, in boost::asio the handler will never be called or in java.nio the selector will never select the channel?</p> <p>Thank you very much.</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.
 

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