If you have two erlang nodes and want to take some actions in case if one node goes down (or network connection is lost) you possible want to use erlang:monitor_node/2,3
functions:
(n1@myhost)1> erlang:monitor_node('n2@myhost', true).
true
then if 'n2@myhost'
node goes down your process will receive message:
(n1@myhost)2> flush().
Shell got {nodedown,n2@myhost}
(note, I did that from erlang shell, that is why I may call flush/0
to see what is in the mailbox of the shell process)
If you interested in certain process, on the second node you may use erlang:monitor/2
(n1@myhost)3> Ref = erlang:monitor(process, {'n2@myhost', some_registered_name}).
#Ref<0.0.0.117>
from now you will receive a message if some_registered_name
goes down and you can take an action.
Also you may be interested in how to write distributed applications