Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio]Does the function of async_read can find the tcp connection has closed?
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2014-04-15 03:37:12


On 15/04/2014 16:04, quoth lx:
> I want to know async_read or async_write can detect the tcp
> connection has closed, or not?

Try it and see.

Generally you should get an error callback for write if the connection
has closed. You may or may not get one for read, depending on how the
connection was closed. (Graceful shutdown or local connections
typically will, unexpected remote disconnection typically won't.)

This is not unique to ASIO; it's how pretty much all TCP sockets work.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net