Erlang gen_tcp:listen options

  • {active, Boolean}

...If the active option is true, which is the default, everything received from the socket will be sent as messages to the receiving process. If the active option is set to false (passive mode), the process must explicitly receive incoming data by calling gen_tcp:recv/N or gen_udp:recv/N (depending on the type of socket). If the active option is set to once (active once), one data message from the socket will be sent to the process. To receive one more message, setopts/2 must be called again with the {active,once} option...

Note: Active mode provides no flow control; a fast sender could easily overflow the receiver with incoming messages. Use active mode only if your high-level protocol provides its own flow control (for instance, acknowledging received messages) or the amount of data exchanged is small.

  • {keepalive, Boolean} - powered by (c) Comet ;)

(TCP/IP sockets) Enables periodic transmission on a connected socket, when no other data is being exchanged. If the other end does not respond, the connection is considered broken and an error message will be sent to the controlling process. Default disabled.

  • {reuseaddr, Boolean}

Allows or disallows local reuse of port numbers. By default, reuse is disallowed.

So the default listening socket options are (overwrite only the differences if needed):

[{active, true},
 {keepalive, false},
 {packet, 0},
 {reuseaddr, false}].