gen_tcp:recv() and client_machine_crash

HP Wei <>
Mon Jun 26 21:15:25 CEST 2006


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} ->
         handle_Bin(...);
     {error, Reason} ->
         handle_exit(...)
   end.

[ 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.

Questions:
   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 ??

thanks
HP




More information about the erlang-questions mailing list