[erlang-questions] active,N — reset counter or increment?

Kenneth Lakin <>
Tue Aug 2 11:08:58 CEST 2016


On 08/02/2016 01:40 AM, Max Lapshin wrote:
> Hi, it is not 100% clear for me from documentation if setting {active,1}
> reset active counter to 1 or increment it by 1?

If the integer passed in is positive, it increments. If it's negative,
it decrements. If this operation causes the socket's message count to be
<= 0, then the socket returns to passive mode.

From the documentation for the active option to inet:setopts:

"If the value is an integer N in the range -32768 to 32767 (inclusive),
the value is added to the socket's count of data messages sent to the
controlling process. ... Once the socket's message count reaches 0,
either because of sending received data messages to the process or by
being explicitly set, the process is then notified by a special message
... that the socket has entered passive mode."

> Can [this sample code] ever receive {tcp_passive, Socket}  ?

Unless some other code is changing the message count for that socket, no.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160802/eb2b87d6/attachment.bin>


More information about the erlang-questions mailing list