Run this notebook

Use Livebook to open this notebook and explore new ideas.

It is easy to get started, on your machine or the cloud.

Click below to open and run it in your Livebook at .

(or change your Livebook location)

<!-- vim: syntax=markdown --> # Node Functions related to VM nodes. Some of the functions in this module are inlined by the compiler, similar to functions in the `Kernel` module and they are explicitly marked in their docs as "inlined by the compiler". For more information about inlined functions, check out the `Kernel` module. ## Function alive?/0 Returns `true` if the local node is alive. That is, if the node can be part of a distributed system. ## Function connect/1 Establishes a connection to `node`. Returns `true` if successful, `false` if not, and the atom `:ignored` if the local node is not alive. For more information, see `:net_kernel.connect_node/1`. ## Function disconnect/1 Forces the disconnection of a node. This will appear to the `node` as if the local node has crashed. This function is mainly used in the Erlang network authentication protocols. Returns `true` if disconnection succeeds, otherwise `false`. If the local node is not alive, the function returns `:ignored`. For more information, see `:erlang.disconnect_node/1`. ## Function get_cookie/0 Returns the magic cookie of the local node. Returns the cookie if the node is alive, otherwise `:nocookie`. ## Function list/0 Returns a list of all visible nodes in the system, excluding the local node. Same as `list(:visible)`. Inlined by the compiler. ## Function list/1 Returns a list of nodes according to argument given. The result returned when the argument is a list, is the list of nodes satisfying the disjunction(s) of the list elements. For more information, see `:erlang.nodes/1`. Inlined by the compiler. ## Function monitor/2 Monitors the status of the node. If `flag` is `true`, monitoring is turned on. If `flag` is `false`, monitoring is turned off. For more information, see `:erlang.monitor_node/2`. For monitoring status changes of all nodes, see `:net_kernel.monitor_nodes/2`. ## Function monitor/3 Behaves as `monitor/2` except that it allows an extra option to be given, namely `:allow_passive_connect`. For more information, see `:erlang.monitor_node/3`. For monitoring status changes of all nodes, see `:net_kernel.monitor_nodes/2`. ## Function ping/1 Tries to set up a connection to node. Returns `:pang` if it fails, or `:pong` if it is successful. ## Examples ```elixir Node.ping(:unknown_node) ``` ## Function self/0 Returns the current node. It returns the same as the built-in `node()`. ## Function set_cookie/2 Sets the magic cookie of `node` to the atom `cookie`. The default node is `Node.self/0`, the local node. If `node` is the local node, the function also sets the cookie of all other unknown nodes to `cookie`. This function will raise `FunctionClauseError` if the given `node` is not alive. ## Function spawn/2 Returns the PID of a new process started by the application of `fun` on `node`. If `node` does not exist, a useless PID is returned. For the list of available options, see `:erlang.spawn/2`. Inlined by the compiler. ## Function spawn/3 Returns the PID of a new process started by the application of `fun` on `node`. If `node` does not exist, a useless PID is returned. For the list of available options, see `:erlang.spawn_opt/3`. Inlined by the compiler. ## Function spawn/4 Returns the PID of a new process started by the application of `module.function(args)` on `node`. If `node` does not exist, a useless PID is returned. For the list of available options, see `:erlang.spawn/4`. Inlined by the compiler. ## Function spawn/5 Returns the PID of a new process started by the application of `module.function(args)` on `node`. If `node` does not exist, a useless PID is returned. For the list of available options, see `:erlang.spawn/4`. Inlined by the compiler. ## Function spawn_link/2 Returns the PID of a new linked process started by the application of `fun` on `node`. A link is created between the calling process and the new process, atomically. If `node` does not exist, a useless PID is returned (and due to the link, an exit signal with exit reason `:noconnection` will be received). Inlined by the compiler. ## Function spawn_link/4 Returns the PID of a new linked process started by the application of `module.function(args)` on `node`. A link is created between the calling process and the new process, atomically. If `node` does not exist, a useless PID is returned (and due to the link, an exit signal with exit reason `:noconnection` will be received). Inlined by the compiler. ## Function start/3 Turns a non-distributed node into a distributed node. This functionality starts the `:net_kernel` and other related processes. This function is rarely invoked in practice. Instead, nodes are named and started via the command line by using the `--sname` and `--name` flags. If you need to use this function to dynamically name a node, please make sure the `epmd` operating system process is running by calling `epmd -daemon`. Invoking this function when the distribution has already been started, either via the command line interface or dynamically, will return an error. ## Examples ```elixir {:ok, pid} = Node.start(:example, :shortnames, 15000) ``` ## Function stop/0 Turns a distributed node into a non-distributed node. For other nodes in the network, this is the same as the node going down. Only possible when the node was started with `Node.start/3`, otherwise returns `{:error, :not_allowed}`. Returns `{:error, :not_found}` if the local node is not alive.
See source

Have you already installed Livebook?

If you already installed Livebook, you can configure the default Livebook location where you want to open notebooks.
Livebook up Checking status We can't reach this Livebook (but we saved your preference anyway)
Run notebook

Not yet? Install Livebook in just a minute

Livebook is open source, free, and ready to run anywhere.

Run in the cloud

on select platforms

To run on Linux, Docker, embedded devices, or Elixir’s Mix, check our README.

PLATINUM SPONSORS
SPONSORS
Code navigation with go to definition of modules and functions Read More