Reputation:
I am trying to create an asynchronous server in C++ using Boost ASIO library, it goes by standard model provided at their webpage, ioservice and worker (session) I am using something like this:
asio::async_read(socket,buffer(data,datalen),[=]( error , len ){
if(error || len==0) disconnect(); else processRequest(data,len);
})
Firstly, it works just fine, when user opens and closes connection - OS does the job.
But problem comes when user disconnects from internet by force, socket remains in "ESTABLISHED" state, though user is already gone, yeah, how would OS handle sending TCP close packet, when internet is not available anymore?
Also problem comes with telephony internet networks, user travels, switches zone from HSDPA to no internet and finally GPRS, old HSDPA socket remains "ESTABLISHED", though user already doesn't use it.
How to detect dead connections like this?
Upvotes: 0
Views: 1827
Reputation: 3759
async_write
which would result in your write handler being called with an error.Upvotes: 2