Is how distribution "works" specified anywhere?
Joe Armstrong
joe@REDACTED
Mon May 17 20:55:22 CEST 2004
On Mon, 17 May 2004, Luke Gorrie wrote:
> Joe Armstrong <joe@REDACTED> writes:
>
> > Is there any internal documentation that specifies how distribution
> > works?
>
> In "on the wire" terms, check out this file in the OTP sources:
>
> erts/emulator/internal_doc/erl_ext_dist.txt
>
> The distribution messages all map simply onto BIFs (SEND, EXIT, etc)
> and it's easy to understand.
>
> > How are things organised with remote Pids? is a remote Pid
> > distinguishable from a local Pid - if so how?
>
> The PID structure includes a node name.
>
Aggh - yes.
Hack city - It seems I can cheat like this:
Suppose I have an Erlang running on host.some.where.se and that to
send messages to It I must use port 111, I'd like to embed this
infromation into all Pids created by this Erlang system.
I can do this as follows. If I write:
$ erl -sname "111-host-some-where-se"
Then create a Pid
> (111-host-some-where-se@REDACTED)1> P=spawn(fun() -> true end).
<0.36.0>
(111-host-some-where-se@REDACTED)2> node(P).
'111-host-some-where-se@REDACTED'
It seems like this string gets embedded in the Pid, since
> term_to_binary(P).
<<131,103,100,0,26,49,49,49,45,104,111,115,116,45,115,111,109,101,45,119,104,101,114,101,45,115,101,64,109,...>>
Which means if I do term_to_binary on anything containing a Pid,
then ship it over the net using any transport method - then I can
extract the string 111-host-some-where-se from the reconstructed term
on any node and thus know that the Pid came from host.some.where.se
and that I have to use port 111 to talk to it.
BTW What is a valid node name?
I'd like to have written the node name like this:
erl -sname '56:123.45.67.89'
{error_logger,{{2004,5,17},{20,50,7}},'Invalid node name: ~p~n',['56:123.45.67.89@REDACTED']}
...
etc.
But this crashes the system.
/Joe
> Luke
>
More information about the erlang-questions
mailing list