[erlang-questions] Checking the Connection

Jordan Wilberding wilbjor@REDACTED
Wed Nov 1 13:58:37 CET 2006


I am not completely sure I understand your question, but for timeouts on 
our small server we wrote, we just start a new thread of the following 
function:

loop_check_alive_nodes(UserList) ->
    receive
        {From, stop} ->
            From ! ok
    after 450000 ->
           DeadUserList = lists:filter(fun(X) -> not 
check_process_alive(element(1, X)) end, UserList),
           ...
    end.

check_process_alive(Pid)
  when is_pid(Pid) ->
        case rpc:call(node(Pid), erlang, is_process_alive, [Pid]) of
            true ->
                true;
            _ ->
                false
        end.

Thanks!
Jordan Wilberding

Kithsiri wrote:
> Hi all,
>       I'm try to find whether the connection to a remote node is present 
> or not. For that I used
> node.ping("remote",2000). I used a timeout period because i want fast 
> reply from remote node. It give reply soon when connection is present, 
> but it is not give reply within timeout period if the connection failed.
> Can someone please give me a way to check the connection state within a 
> limited period of time.
>
> Thank You,
>       Kithsiri.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>   




More information about the erlang-questions mailing list