gen_tcp:recv() and client_machine_crash

Yani Dzhurov yani.dzhurov@REDACTED
Tue Jun 27 12:36:03 CEST 2006


Why don't trying using the keep alive option for tcp socket:

{keepalive, Boolean} (TCP/IP sockets) 
Enables/disables periodic transmission on a connected socket, when no other
data is being exchanged. If the other end does not respond, the connection
is considered broken and an error message will be sent to the controlling
process. Default disabled.

This is from the inet module docs . I think this should work for you.



-----Original Message-----
From: owner-erlang-questions@REDACTED
[mailto:owner-erlang-questions@REDACTED] On Behalf Of HP Wei
Sent: Monday, June 26, 2006 10:15 PM
To: erlang-questions@REDACTED
Subject: gen_tcp:recv() and client_machine_crash

I have a server (written in Erlang) which handles
clients' request(s) through tcp_socket by
the following piece of psudo-code:

handle_request(Sock) ->
   case gen_tcp:recv(Sock, 0) of
     {ok, Bin} ->
     {error, Reason} ->

[ Note: The client code is written in python. ]

I want the handle_exit() to handle three abnormal-exit situations
that may occur on the client side.
(1) the client's code gets Control_C exit;
(2) the client's code gets killed by 'kill -9 pid'
    [ under UNIX ];
(3) the machine that the client is running on
    crashes !

For (1) and (2), the part 'handle_exit()' in the
above snippet gets executed as expected.

However, we had a client_machine_crash this morning
but the handle_exit(..) did not seem to get executed.

   Is it supposed to be executed ?
   If yes, I will check the other part of the server-code.
   If no, then what is the proper way to detect a
   machine crash ??


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3326 bytes
Desc: not available
URL: <>

More information about the erlang-questions mailing list