An Erlang node is an executing Erlang runtime system that has been given a
name. Multiple nodes can run on a single host, but they can also be
running on different host computers, too, as shown in Figure 11-1, where three nodes are
running on the hosts
FCC in their respective subnetworks.
Figure 11-1. Three nodes running on two hosts
As a first example, we’ll look at two nodes running on the same
STC, as shown in Figure 11-2. To run a node, the
erl command needs to be given the
sname flag (the
name flag can also be used; we’ll discuss this
shortly). For example:
erl -sname foo Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:2] [async-threads:0] [kernel-poll:false] Eshell V5.6.3 (abort with ^G) (foo@STC)1>
Note that the prompt in the Erlang shell displays the name of the
node, as well as its host computer:
foo@STC. This is called the (unique)
identifier of the node.
A similar command,
will set up a second node on the
Figure 11-2. A first example: two nodes on one host
To understand what happens next, you need to look at the module
dist.er1. This contains the function
t(From) -> From ! node().
The function takes as a parameter a pid,
From, and in its single action it sends a message to the process ...