unable to reconnect to server
Matthias Lang
matthias@REDACTED
Mon Jan 31 12:58:14 CET 2005
Dietmar Schaefer writes:
> I am trying to establish a connection to a client via gen_tcp:
[...]
> When I terminate the client and try to start it again I get
>
> Error in process <0.322.0> on node 'cmmc@REDACTED' with exit value:
> {badarg,[{erlang,register,[test,<0.325.0>]},{test3,loop,1}]}
>
> What has erlang:register to do with that ?
>
> What's wrong anyway ?
>
> Any hint ?
The program you posted isn't complete (it calls fill/2, but you
haven't provided fill/2), so I'll just take a guess.
register/2 is failing because you try to register the spawned process
every time a client connects. Here's the manual:
| register(Name, P)
|
| Associates the name Name with the port or process identity P. Name,
| which must be an atom, can be used instead of a port or pid in the
| send operator (Name ! Message).
|
| Returns true.
|
| Failure: badarg if P is not an active port or process, or if P is on
| another node, or if the name Name is already in use, or if the port or
| process is already registered (it already has a name), or if the name
| Name is not an atom, or if Name is the atom undefined.
So, if you do this, it's going to fail the second time around:
loop() ->
register(test, spawn(fun() -> timer:sleep(10000) end)),
loop().
Matthias
More information about the erlang-questions
mailing list