[erlang-questions] parallel tcp server closed once spawned

YC <>
Tue Oct 16 04:30:50 CEST 2007

Update -

it turns out that if I call para_server directly instead of using spawn, it
works.  Why this is the case, I'm not fully certain, but my guess is that if
I call para_server via spawn, then the first process dies right after it
spawns the accept processes, and causes the connection to close, and hence
when par_connect is evaluated it finds the listener closed.

If I miss something, please let me know.  Thanks,

> I'm going through the exercises in Programming Erlang, and I run into a
> puzzling error with the parallel_server example.  Below is my > almost
> verbatim copy from the book.
> When I try to run the code, I ended up with a badmatch error.
> ()12> P5 = spawn(nano_server, para_server, []).
> <0.67.0>
> =ERROR REPORT==== 15-Oct-2007::18:04:30 ===
> Error in process <0.68.0> on node ' ' with exit value:
> {{badmatch,{error,closed}},[{nano_server,par_connect,1}]}
> > So gen_tcp:accept(Listen) returns {error, closed} instead of {ok,
> Socket}, but I'm not sure why, as the  > gen_tcp:listen line appears to
> run correctly (and I've also verified that the seq_server version works).  I
> must be missing something > extremely obvious here.
> > Any thoughts are appreciated, thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20071015/d7c9df20/attachment.html>

More information about the erlang-questions mailing list