Re: Network buffering question
- From: "David" <FlyLikeAnEagle@xxxxxxxxxx>
- Date: Tue, 29 Aug 2006 02:01:05 GMT
Hello Till,
On Mon, 28 Aug 2006 22:18:29 UTC, Till Crueger <TillFC@xxxxxxx> wrote:
Hi,
I hope this is the best newsgroup for this topic. I looked around, but I
couldn't find any more specific newsgroups.
I am working on some network code right now. For help I am using "Beej's
Guide to Network Programming". Now I stumbled upon the chapter about data
encapsulation. I get the point that you should send across the Network
some information about how much data you have been sending, so you can
reconstruct the packets correctely. So far I think I got everything.
However then he says that you need to make your buffer twice as large as a
single packet, because you might actually read past the packet you are
trying to handle at the moment. Since you can tell recv() how much you
want to recieve couldn't you just make sure this wont ever happen? I would
have tried something like this:
read size information
check if everything was recieved
read the rest (let recv() know how much to read)
Or is there some problem to this, so you actually need to use bigger
buffers or circular buffers?
Thanks for your help,
Till
Larger buffers generally help improve throughput. It helps when your
protocol is sending lots of data back and forth. It won't help when
your communication processes exchange a simple message back and forth.
The reason for the improvement is due to what the system has to do
to satisfy your request. The system can give you a couple bytes at
a time if that is what you need, but the cost of reading just a few
bytes might be thousands of lines of code or worse hidden by the
TCP interface calls. It may be a little harder for you to grab all
the data available and use it as you need it, but that is usually
much better performance wise.
David
.
- References:
- Network buffering question
- From: Till Crueger
- Network buffering question
- Prev by Date: Re: Network buffering question
- Next by Date: Re: Code Comprehension
- Previous by thread: Re: Network buffering question
- Next by thread: Re: Network buffering question
- Index(es):
Relevant Pages
|