lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] TCP message merging fault


From: Çağlar AKYÜZ
Subject: Re: [lwip-users] TCP message merging fault
Date: Mon, 05 Mar 2007 21:39:38 +0200
User-agent: Mozilla Thunderbird 1.5.0.10 (Windows/20070221)

Kieran Mansley wrote:
On Mon, Mar 05, 2007 at 07:40:35PM +0200, ?a?lar AKY?Z wrote:

Should I play with my lwIP options or should I review my linux network programming knowledge? Moreover, can I investigate this problem using Ethereal?

That's just the way TCP works - the units in which you write data bear
no resemblance to the units you application at the other end will read
data.  The TCP protocol is free to chop and merge the data you give it
as it likes, as long as it delivers it in the right order.  Think of
it as a stream of data rather than being packetised.

If you want to get data in certain sized chunks, (e.g. to get a whole
command) you have two choices.  If you know the length of a chunk in
advance, you can loop around read until you have enough (and keep any
extra you get for the next read).  Or, if the units you application
sends in are variable length get it to first write the length of this
chunk, followed by the chunk itself.  Then your reading end can read
the length first, and know how much to expect, and loop as before
until it gets this much.  The sockets API would take some of this
hassle out for you, but in most cases you're better off with the raw
API on lwIP.

Kieran

I see. Thanks for the tips. I'll modify my program accordingly.

I wish I would have written this message to the list two days ago. It would save me from spending 36
hours of useless struggling. :)

Kind Regards
Caglar AKYUZ





reply via email to

[Prev in Thread] Current Thread [Next in Thread]