[erlang-questions] Pinging the great unknown
Donald Steven
t6sn7gt@REDACTED
Thu May 19 00:55:44 CEST 2016
Thanks Hugo, that's very helpful.
Don
On 5/18/2016 5:12 PM, Hugo Mills wrote:
> On Wed, May 18, 2016 at 04:40:36PM -0400, Donald Steven wrote:
>> Hi all,
>>
>> Simple newbie question for someone just learning. I'm getting the hang of sending and receiving messages work and pids, but how does a process ping a message into the great unknown that says basically: "Hello out there, I'm here, I exist..." if you don't know what if any processes are 'out there' to actually receive a message?
> One approach: Process A (the receipient) registers itself with
> register/2, using an atom as a name. Process B (the sender) uses the
> same atom to look up the pid of A, with whereis/1. So, the initial
> "connection" between the two comes from the programmer knowing that
> process A registers under a particular name, and then telling process
> B to use that name. There's a simple built-in registry (register/2,
> whereis/1), or there are more complex third-party registries (like
> gproc).
>
> Another approach: Process A starts. It starts process B, passing in
> its own pid as a parameter. Alternatively, process C could have
> started both A and B, getting the pid of A after it's running, and
> passing that to B as a parameter on startup.
>
> The first approach is more typical, particularly in the case where
> process A is a server of some kind.
>
> Hugo.
>
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
More information about the erlang-questions
mailing list