Tcp {active, true} problem

Tony Rogvall tony@REDACTED
Tue Aug 8 13:19:14 CEST 2000

Martin Logan wrote:

> Hello all,
>         I am writing a proxy server in erlang. I have run into a slight
> problem with gen_tcp. I am using {active, true} and receiving with
> receive
>         {tcp, Socket, Packet} ->
> end
> If I send packets to this at a 500 milliseconds apart I receive all of the
> packets perfectly and the proxy works well. My problem arises when I send
> a number of packets quickly( < 500 ms). I receive them as one large ascii
> string. I was wondering, befor I write a parser of sorts, if there is some
> other way to deal with this problem.
>                         Thank you,
>                         Martin Logan

As you already seen you can use {packet,1 | 2 | 4} to let the erlang driver
packetize the data for you.
I think the option {nodelay, true} might be of interest in this case.
TCP_NODELAY option is used to set aside the buffering algorithm in the os
kernel tcp/ip driver, leading to that the data is sent as quickly as possible
and not optimized as stream data.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: tony.vcf
Type: text/x-vcard
Size: 352 bytes
Desc: Card for Tony Rogvall
URL: <>

More information about the erlang-questions mailing list