Sending a message to another node
Ulf Wiger
ulf@REDACTED
Sat Mar 12 15:08:35 CET 2005
Den 2005-03-12 14:02:44 skrev <erlang-questions@REDACTED>:
> (one@REDACTED)13> {pid(0,35,0), 'two@REDACTED'} ! hello2.
>
>
>
> =ERROR REPORT==== 12-Mar-2005::07:54:48 ===
>
> Error in process <0.54.0> on node 'one@REDACTED' with exit value:
> {badarg,[{erl_e
>
> val,eval_op,3},{erl_eval,expr,5},{shell,exprs,6},{shell,eval_loop,3}]}
>
>
> Am I using a wrong syntax for sending messages to a known pid, or
> referencing the pid incorrectly at node two? If I know a pid on node
> two, is it possible to send a message to it using the ! command?
You are using the wrong syntax to begin with, and you
shouldn't ever use pid/3 except for debugging.
{Process, Node} ! Message assumes that Process is a registered
name on Node. As such, it must be an atom.
The syntax for sending to a pid is always Pid ! Message,
but if you call pid(0,35,0), this generates a _local_ pid
(as indicated by the first digit, the "node index").
The way to make a remote pid known is to send it somehow in
a message. You should never assume that a pid will always
have the same "number", nor that a node index of a remote node
is the same for all sessions. Basically, you shouldn't make
any assumptions about the value of av pid.
/Uffe
--
Använder Operas banbrytande e-postklient: http://www.opera.com/m2/
More information about the erlang-questions
mailing list