The net kernel is a system process which must be running
for distributed Erlang to work. The purpose of this process is to implement parts
of the BIFs spawn/4 and spawn_link/4, and to provide
authentication and monitoring of the network.
An Erlang runtime system can be started from the UNIX command line as follows:
% erl -name foobar
With this command line, the net_kernel is started as
net_kernel:start([foobar]). See erl(1).
This is done by the system itself, but the start([Name]) function
can also be called directly from the normal Erlang shell prompt,
and a normal Erlang runtime system is then converted to a node. The
kernel can be shut down with the function
stop(), but only if the kernel was not started by the system itself.
The node is then converted into a normal Erlang runtime system. All other
nodes on the network will regard this as a total node crash.
If the system is started as % erl -sname foobar,
the node name of the node will be foobar@Host, where Host is the
short name of the host (not the fully qualified domain name). The -name
flag gives a node with the fully qualified domain name. See erl(1).
The system can be started with the flag
-dist_auto_connect to control automatic connection of
remote nodes. See connect_node/1 below and erl(1).
As the net kernel runs in the 'user space', it is easy
to provide another net kernel which is tailor made for
a specific application. For example, the user supplied kernel can
limit the set of registered processes which can be accessed
from remote nodes, or it can spawn
a new process for each {nodeup, Node} message
and perform some application specific user authentication,
a log-in procedure for example. The kernel_apply(M, F, A)
function is supplied for this purpose.
A process which evaluates this function receives copies of the
{nodeup, Node} and
{nodedown, Node} messages that the net kernel receives from
the runtime system. The flag Flag is set to true to
turn the service on, and false to turn it off.
In a simple way, this function limits access to a node from a specific number of named nodes. A node which evaluates this function can only be accessed
from nodes listed in the NodeList variable.
Any access attempts made from nodes not listed in NodeList are rejected.
Explicitly establishes a connection to the node
specified by the atom Node.
Returns true if succesful, false if not,
and ignored if net_kernel is not started.
This function is only necessary if the system
is started with the flag -dist_auto_connect.
See erl(1).