[erlang-questions] accept part of a server
Bengt Kleberg
bengt.kleberg@REDACTED
Fri Apr 3 13:32:45 CEST 2009
Greetings,
If you do 1), and want to use an active socket, you will have to assign
a new controlling process Pid to S.
If you do 2) the right process is already in control. LS is not a
problem, since the accept call does not have to be issued from the
socket owner process.
Read http://erlang.org/doc/man/gen_tcp.html for more information.
bengt
On Fri, 2009-04-03 at 11:40 +0200, Gamoto wrote:
> I saw two approaches for the accept part of a server:
>
> Approach 1:
> do_accept(LS)->
> case gen_tcp:accept(LS) of
> {ok,S}->spawn(...handle(S)...),
> do_accept(LS);
> Other-> ...
> end.
>
> Approach 2):
> do_accept(LS)->
> case gen_tcp:accept(LS) of
> {ok,S}-> spawn(...do_accept(LS) ...),
> handle(S);
> Other-> ...
> end.
>
> What is the better approach and the criteria for chosing (crash, supervision, ...) ?
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list