[erlang-questions] gen_tcp custom framing

Peter Lund <>
Fri Oct 5 16:46:14 CEST 2007

Joern skrev:
> Dear erlang-questions,
> having to deal with a non-inet supported packet format on TCP / IP
> (STX / ETX limited, fixed size header, 7-bit encoded payload length) I
> am wondering what the best practice might be. Right now I spawn_link
> into a passive recv loop - is it possible to add a custom framing
> behaviour to inet and get to use { active, once }?
Is this UCP or CIMD perhaps? :)

Standard practice or not, I do not know, but some number of times, I
have now implemented myself buffering of incoming IP-segments into a
binary and each time new data comes in I try to find one or more complete
packages in this buffer. If I find it I handle the packages.

In R9, I have also forced to match each packet more than one time since
an initial length value read out first, cannot be used later in the same
binary match statement, but I am guessing that this problem now is history
when using R11.


More information about the erlang-questions mailing list