[erlang-questions] gen_tcp under gen_server design
Andre Nathan
andre@REDACTED
Mon Aug 2 05:25:45 CEST 2010
Hi Martin
On Fri, 2010-07-30 at 11:57 -0500, Logan, Martin wrote:
> Andrew, BTW – you should not have to use controlling process. Have the
> listen sock spawned in your application behaviour implementation
> module, then pass it through to each acceptor which blocks on accept
> in the handle_info(timeout clause which is prompted by using a timeout
> of 0 out of init/1. Once you accept call into the simple_one_for_one
> supervisor that is responsible for spawning off your acceptors and
> have it spawn another one to wait for the next connection while the
> first chugs along processing on a socket it already owns by virtue of
> the fact that it accepted it. There is no worry here between accepting
> one connection and spawning another to accept the next because the OS
> queues up pending connections of which the call to accept/1 only pulls
> off the first one.
>
> Hope that helps.
Thanks, I wouldn't have thought of doing the accept call in handle_info.
Is there any advantage of spawning a new acceptor process every time a
new connection arrives and do the request processing in the original
process, as opposed to spawning a new worker process on each request and
using a single acceptor?
Thanks again,
Andre
More information about the erlang-questions
mailing list