asio, check remote socket open
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 ______________________________________ Scanned and protected by Email scanner
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).
Not really. To detect peer disconnection you can perform an async_read on that socket, and in most cases it will call its handler with some error. But this method doesn't always work - eg., in case of a "non-graceful" cable disconnection.
I am not in a position to call async_read, as it will read out some valuable
data (if the connection is not closed).
Al least is there any "dirty way" to do this?
Thanks a lot,
Lloyd
----- Original Message -----
From: "Igor R"
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). Not really. To detect peer disconnection you can perform an async_readon that socket, and in most cases it will call its handler with someerror. But this method doesn't always work - eg., in case of a"non-graceful" cable disconnection._______________________________________________Boost-users mailing listBoost-users@lists.boost.orghttp://lists.boost.org/mailman/listinfo.cgi/boost-users
______________________________________ Scanned and protected by Email scanner
Thank you very much Igor.
----- Original Message -----
From: "Igor R"
I am not in a position to call async_read, as it will read out some valuable> data (if the connection is not closed).>> Al least is there any "dirty way" to do this? Not that I know of.Try to ask on asio list._______________________________________________Boost-users mailing listBoost-users@lists.boost.orghttp://lists.boost.org/mailman/listinfo.cgi/boost-users
______________________________________ Scanned and protected by Email scanner
participants (3)
-
Eric MALENFANT
-
Igor R
-
Lloyd