>Hi,

>I have a server application. It listens for connection and receives data. when data is received, the receive "handler routine" is called. Inside the handler there is async timer. This timer's handler again initiates a new >timer.This keeps on executing. During this time, the remote client which connects to the server closes the connection "intentionally". Inside the timer handler routine, is there any way to chek the connection is closed or >not? (From the timer handler, I can access the socket and io_service).

>I have tried with

>socket::is_open(), socket::remote_endpoint(), they are successfull and does not throw any exception.

>Thanks a lot,

>  Lloyd 


As it was said, even reading is not reliable in case of a cable disconnection or even some strange ISP interruption.

The only way is to try writing something to the user (a sort of application defined ping), beacause this should trigger a tcp error at one moment if the connection was closed.

Needless to say, that the tcp client should do the same to detect properly closed connections.

You can even add a timeout in both sides to monitor user or server activity (incoming and outgoing data), and close the connection if the timeout is reached....