[erlang-questions] gen_tcp issue when socket interrupted by peer

Morgan Segalis <>
Sat Feb 9 15:08:17 CET 2013


Hi everyone, 

I'm facing an issue when the client wrongly interrupt the connection to the server...

Actually, the client is a phone... When the phone goes from Wifi to (3G or No Connection) the tcp connection opened while it was on Wifi is still opened on the server.

The weird thing is, If I send data to the "closed" socket, gen_tcp:send returns always ok, although it will never been received...
I though that TCP was all about stability and message receiving (unlike UDP).

Is that a normal behavior ? Or I am doing something wrong ?

I'm using gen_server behaviour, and my socket options are : 

-define(TCP_OPTIONS, [list, 
{packet, 0}, 
{active, once}, 
{reuseaddr, true}, 
{mode, list}, 
{backlog, 128}, 
{send_timeout, 1},
{keepalive, true}]).

of course I handle all tcp events like tcp_closed and tcp_error

Please help !

Thank you.


More information about the erlang-questions mailing list