Passive TCP sockets

I understand the basic difference between active and passive sockets and why we often use active_once in practice. The following paragraph from LYSEFGG raised a few questions:

The idea is that if all packets coming from the outside world are blindly accepted by Erlang and then converted to messages, it is somewhat easy for someone outside of the VM to flood it and kill it. Passive mode has the advantage of restricting how and when messages can be put into the Erlang VM, and delegating the task of blocking, queuing up, and dropping messages to the lower-level implementations.

My questions are:

  1. If the received packets aren’t in Erlang VM, where are they buffered? How they are handled by OS?
  2. Can OS buffer also overflow? What happens when it does?

Those questions aren’t directly about Erlang but I’d appreciate any insight provided :smiley:


The kernel buffers data until the user process (Erlang) reads it. If that fills up, it tells the sender to slow down or stop, see e.g.: TCP Series #4: The TCP Receive Window and everything to know about it