Update - <br><br>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.
<br><br>If I miss something, please let me know. Thanks,<br>yc<br><br><br><div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> 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. <br></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> When I try to run the code, I ended up with a badmatch error.
<br><br><div style="margin-left: 40px;">(emacs@localhost)12> P5 = spawn(nano_server, para_server, []).<br><0.67.0><br><br>=ERROR REPORT==== 15-Oct-2007::18:04:30 ===<br>Error in process <0.68.0> on node '
emacs@localhost' with exit value: {{badmatch,{error,closed}},[{nano_server,par_connect,1}]}<br></div><br>> So <span style="font-family: courier new,monospace;">gen_tcp:accept(Listen)</span> returns <span style="font-family: courier new,monospace;">
{error, closed}</span> instead of <span style="font-family: courier new,monospace;">{ok, Socket}</span>, but I'm not sure why, as the <span style="font-family: courier new,monospace;"> > gen_tcp:listen</span> line appears to run correctly (and I've also verified that the seq_server version works). I must be missing something > extremely obvious here.
<br><br>> Any thoughts are appreciated, thanks.</blockquote><div><br><br></div></div>