问题
I've got a simple module:
-module(dist).
-compile([add/3]).
add(From,X,Y) ->
From ! X+Y.
And I'm starting two nodes.
One with
erl -sname foo
and another with
erl -sname bar
On the bar node I'm doing:
> c(dist).
{ok,dist}
> self().
<0.37.0>
> spawn('foo@unknown-00-23-6c-83-af-bd', dist, add, [self(), 3, 5]).
But the reponse I get is:
Error in process <0.48.0> on node 'foo@unknown-00-23-6c-83-af-bd' with exit value: {undef,[{dist,add,[<8965.37.0>,3,5]}]}
What does this error mean? I wondered if it meant that my foo node doesn't have this module defined? I didn't think it needed it, but the problem wasn't fixed by compiling dist in the foo node so I guess this isn't the problem.
回答1:
Export the add/3. Instead of a compile option.
-export([add/3]).
回答2:
if in the first node you use nl(module) then the beam of that module will be loaded to all connected nodes
来源:https://stackoverflow.com/questions/4199823/simple-distributed-erlang