这绝对没有意义。 <0.X.0> 是您的本地 Pid,<D.X.0> - 分布式变体,其中 D 是节点的编号。 More information about Pid strcuture。但是D 对于不同的节点会有所不同。所以在本地你无法获得这些信息。
当然,你可以实现特殊的 RPC 调用,它将返回给调用者他的(调用者的)分布式 Pid。但结果会因答案而异。为确保这一点,请尝试简单:
启动三个不同的节点并将shell注册为self。
第一
erl -sname one
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
(one@Alexeys-MacBook-Pro)1> node().
'one@Alexeys-MacBook-Pro'
(one@Alexeys-MacBook-Pro)2> register(shell, self()).
true
第二
erl -sname two
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
(two@Alexeys-MacBook-Pro)1> node().
'two@Alexeys-MacBook-Pro'
(two@Alexeys-MacBook-Pro)2> register(shell, self()).
true
第三
erl -sname three
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
(three@Alexeys-MacBook-Pro)1> node().
'three@Alexeys-MacBook-Pro'
(three@Alexeys-MacBook-Pro)2> register(shell, self()).
true
现在返回节点one,尝试
(one@Alexeys-MacBook-Pro)6> net_kernel:connect('two@Alexeys-MacBook-Pro').
true
(one@Alexeys-MacBook-Pro)7> net_kernel:connect('threeAlexeys-MacBook-Pro').
true
(one@Alexeys-MacBook-Pro)8> {shell, 'two@Alexeys-MacBook-Pro'} ! {hello, from, self()}.
{hello,from,<0.147.0>}
(one@Alexeys-MacBook-Pro)82> {shell, 'three@Alexeys-MacBook-Pro'} ! {hello, from, self()}.
{hello,from,<0.147.0>}
检查节点两个
的结果
(two@Alexeys-MacBook-Pro)3> flush().
Shell got {hello,from,<6767.147.0>}
ok
和树
(three@Alexeys-MacBook-Pro)3> flush().
Shell got {hello,from,<6803.147.0>}
ok
如您所见,Pid 的第一部分不同:<6767.147.0> 和 <6803.147.0>。