[erlang-questions] Wondering on active TCP socket

Nahuel Greco <>
Thu Aug 12 17:21:25 CEST 2010


On Thu, Aug 12, 2010 at 11:58 AM, Kaiduan Xie <> wrote:
> Nahuel, thank you for the insightful clarification.
>
> How erlang VM retrieve packet from TCP stack for active socket? Does
> it retrieve the packet, wrap it as a message and send to the
> controlling process every time underlying OS TCP stack receives a
> packet (here packet is a stream of bytes) from network? Where can I
> find more information? Which moudles/source files?
>

It collects data from the TCP incoming buffer, and when a packet is
complete wraps it in a message and sends it to the controlling
process. What a packet is depends on the options you set to the
socket. See the {packet, PacketType} option here:

http://erldocs.com/R14A/kernel/inet.html?i=0&search=inet:setopts#setopts/2

See also the gen_tcp documentation.

Saludos,
Nahuel Greco.


More information about the erlang-questions mailing list