net_adm:world/0
查找并连接本地主机上的所有节点
用法:
world() -> [node()]
内部实现:
-spec world() -> [node()].
world() ->
world(silent).
-spec world(Arg) -> [node()] when
Arg :: verbosity().
world(Verbose) ->
case net_adm:host_file() of
{error,R} -> exit({error, R});
Hosts -> expand_hosts(Hosts, Verbose)
end.
这个函数查找本地主机上的 .hosts.erlang 文件上的节点信息,并对这些节点进行模拟 ping 操作,最后返回一个可以成功 ping 到的节点列表
这个函数经常用在当一个节点启动时,网络上的其他节点名最初不被知道。
如果调用 net_adm:host_file() 时报{error, Reason} 的错,该函数则返回 {error, Reason}。
net_adm:world().