Erlang获得给定Pid的Sname

Erlang获得给定Pid的Sname,erlang,otp,Erlang,Otp,我有三个Erlang节点在不同的机器上运行,启动如下: erl -sname test@box1 -cookie cookie (on one machine) erl -sname test@box2 -cookie cookie (on another machine) erl -sname test@box3 -cookie cookie (on a third machine) 盒子1是主人。框2和框3是工人。当Box1向Box2和Box3发送任务时,它们都会响应结果。但是,此时,Bo

我有三个Erlang节点在不同的机器上运行,启动如下:

erl -sname test@box1 -cookie cookie (on one machine)
erl -sname test@box2 -cookie cookie (on another machine)
erl -sname test@box3 -cookie cookie (on a third machine)

盒子1是主人。框2和框3是工人。当Box1向Box2和Box3发送任务时,它们都会响应结果。但是,此时,Box1只知道框2和框3上Erlang进程的PID。在给定pid的情况下,有没有办法获取远程进程的sname?或者远程进程必须发回其主机名吗?

您可以使用node/1功能:

3> node(self()).
nonode@nohost

节点/1的参数可以是pid、引用或端口。它甚至可以在守卫测试中使用。非常感谢!我甚至没有意识到有一个节点/1。这大大简化了我必须进行的更改。