In my mochiweb application, I am using a long HTTP request. I wanted to detect when the user connection had died, and I figured out how to do it:
Socket = Req:get(socket), inet:setopts(Socket, [{active, once}]), receive {tcp_closed, Socket} -> % handle clean up Data -> % do something end.
This works when: the user closes the tab / browser or refreshes the page. However, when the Internet connection suddenly dies (say the Wi-Fi signal is lost suddenly) or when the browser crashes, I cannot detect tcp closure.
Am I missing something, or is there any other way to achieve this?
jeffreyveon
source share