[erlang-questions] 2 (unrelated) questions.
Paul Barry
paul.james.barry@REDACTED
Thu Oct 27 09:58:30 CEST 2011
Thanks Geoff and Ahmed for those answers. :-)
I'm interested to know why register() doesn't support remote PIDs, but
I guess that's a question for the language implementers. Of course,
that said, it looks like the "global" library is what I'm after: "In
this module, the equivalent of the register/2 and whereis/1 BIFs (for
local name registration) are implemented, but for a network of Erlang
nodes." - so there's my answer right there.
Thanks for that pointer (Geoff) and thanks for also for the link to
the list archive (Ahmed). I'll be sure to check there *first* from
now on.
Regards.
Paul.
On 26 October 2011 21:34, Geoff Cant <nem@REDACTED> wrote:
> On 2011-10-26, at 08:25 , Paul Barry wrote:
>> Q2. Being able to register a spawned process is cool, but why can't I
>> register a process that is spawned remotely? That is, why does this
>> line of code give me a "badarg"?
>>
>> register(the_board, spawn('server@REDACTED', displayboard,
>> putmessage, [])).
>
>
> You can only register local pids and ports. I'm not sure why this restriction is enforced - maybe the erts people have more information.
>
> In practice it's easy to work around. Register the name on the remote node and then use the {the_board, 'server@REDACTED'} ({RegisteredName, Node}) form instead of using a bare registered name or pid. This form is a valid argument to the ! send function.
>
> As others have mentioned there are other process registries you can use (gproc, ngproc, proc_reg, global) that allow the registration of remote pids (and usually allow names to be terms instead of just atoms).
>
> Cheers,
> --
> Geoff Cant
>
>
>
>
>
--
Paul Barry, w: http://paulbarry.itcarlow.ie - e: paul.barry@REDACTED
Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland.
More information about the erlang-questions
mailing list