[erlang-questions] TCP flow control problem

Bengt Kleberg <>
Mon Jan 31 08:49:15 CET 2011


Greetings,

TCP is a stream protocol. It does not preserve message boundaries. You
have to handle that yourself. Sleeping one second is one way. When you
do not sleep, how do you separate the messages?


bengt

On Sun, 2011-01-30 at 23:38 +0100, Nav wrote:
> I have implemented two TCP servers using gen_fsm, and gen_server, respectively.
> I am using {active, once} option, after getting each message.
> 
> When I try to send data from one side to another in a loop, the data
> gets corrupted (first 1 or 2 message arrive ok, but following gets
> corrupted) when it arrives at other side.
> 
> However, if I put a timer:sleep(1000) before sending each message,
> then everything seems to go fast.
> 
> What seems to go wrong by sending data too fast? Do I need to set some
> more socket options?
> 
> Thanks, Nav
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
> 



More information about the erlang-questions mailing list