Erlang - node 方法

这用于确定进程需要运行的节点的值。 由于分布式编程是用来在不同的节点上运行函数的,所以当想要在不同的机器上运行程序时,这个函数就非常有用。

语法

node()

参数

  • None

返回值

这将返回本地节点的名称。 如果节点不是分布式的,则返回nonode@nohost

例如

-module(helloworld). 
-export([start/0]). 

start() ->
   io:fwrite("~p",[node()]).

输出

当我们运行上面的程序时,我们将得到以下结果。

nonode@nohost

❮ erlang_distributed_programming.html