[erlang-questions] Question on building a Parallel Server
Harit Himanshu
harit.subscriptions@REDACTED
Tue Jan 27 15:43:44 CET 2015
Hello
As I learn from Programming Erlang, the following is a way to create a
parallel server
start_parallel_server() ->
{ok, Listen} = gen_tcp:listen(...), spawn(fun() -> par_connect(Listen) end).
par_connect(Listen) ->
{ok, Socket} = gen_tcp:accept(Listen), spawn(fun() -> par_connect(Listen)
end), loop(Socket).
I wanted to dissect this code to understand what's going on.
*Questions*
1. When we call *start_parallel_server() * on a single machine, a
separate process is started (which is controlling process?) executing
*par_connect*, correct?
2. When *gen_tcp:accept* accepts a new connection, immediately a new
process is created executing *par_connect(Listen)*. This makes sure that
we can accept more requests from the client. Now who is the controlling
process for this new process? is the same as Listen?
Thanks
+ Harit Himanshu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150127/3e516582/attachment.htm>
More information about the erlang-questions
mailing list