|
Re: Testing socket for disconnect: msg#00035lib.boost.asio.user
Stas Khirman wrote: > What is 'ASIO-approved' way to check if TCP socket had been disconnected > by remote peer while no outstanding read/write operation. Actually maintaining an outstanding read operation is usually the best way, since you will be notified of the disconnection as soon as it occurs. You could probably also call the remote_endpoint() function and check if it fails, but that function is not really intended for that usage. However, as Richard suggested, you would want to investigate higher-level mechanisms for detecting connection loss if you want to be able to detect all network failures, etc. > Related question - Did I understand correctly that if I have an > outstanding read/write it will be completed with asio::error:: > connection_aborted error on remote peer disconnect ? . No. If the peer closes the connection cleanly, the read will get error::eof. If the connection is closed due to error, you may get something like error::connection_reset, error::network_reset etc. Typically you should just distinguish between graceful closure (i.e. error::eof) and something else. Cheers, Chris ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Testing socket for disconnect: 00035, Richard Dingwall |
|---|---|
| Next by Date: | multiple ports on same io_service, attaching other services: 00035, Charlls Quarra |
| Previous by Thread: | Re: Testing socket for disconnecti: 00035, Richard Dingwall |
| Next by Thread: | multiple ports on same io_service, attaching other services: 00035, Charlls Quarra |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |