[erlang-questions] Erlang OTP design principle

Per Hedeland per@REDACTED
Tue Jul 10 15:02:32 CEST 2007

igwan <igwan@REDACTED> wrote:
>I had a similar issue last month. This post might be of interest to you 
>: http://www.erlang.org/pipermail/erlang-questions/2007-June/027555.html
>It seems that upon receiving the message you have to get opts from the 
>listening socket, and set them to the new connection socket.

That's entirely optional (but may be a good idea in generic code).  It's
just that gen_tcp wants to present an interface where all options set on
the listen socket are "inherited" by the connection socket. E.g. you can
include {active, once} in the options given to gen_tcp:listen/2 even
though it's meaningless for the listen socket, and all the connection
sockets resulting from 'accept' calls will have {active, once} set from
the start - no need to do inet:setopts/2 on them. Kind of nice if you
know about it and can rely on it, but I don't see it mentioned in the
man page other than implicitly by way of the example.

So, if you know that you haven't set any of the options in the fairly
short list in prim_inet:accept_opts/2 on the listen socket, or if you
are going to set them on the connection socket anyway, there's no need
to retrieve them from the listen socket and set them on the connection

--Per Hedeland

More information about the erlang-questions mailing list