Network buffering question



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

--
Please add "Salt and Pepper" to the subject line to bypass my spam filter

.



Relevant Pages

  • Re: Network buffering question
    ... I hope this is the best newsgroup for this topic. ... I am working on some network code right now. ... single packet, because you might actually read past the packet you are ... buffers or circular buffers? ...
    (comp.programming)
  • Re: CAsyncSocket and receive
    ... If you want to know the length of a packet, it is up to you to determine how you are going ... except that you are guaranteed that the sum of all characters received will ... network feels like delivering. ... the use of Nagle's Algorithm (which buffers packets up on the sender side), ...
    (microsoft.public.vc.mfc)
  • alt.2600 FAQ Revision .014 (2/4)
    ... One type of firewall is the packet filtering firewall. ... Dropping packets instead of rejecting them greatly increases the time required to scan your network. ... Port scanning UDP ports is much slower than port scanning TCP ports. ... Chartreuse Use the electricity from your phone line Cheese Connect two phones to create a diverter Chrome Manipulate Traffic Signals by Remote Control ...
    (alt.2600)
  • Re: Cant establish a network.
    ... The current newsgroup seems to do it about a day after each ... still see the replies coming from other posters in other groups. ... resolve the problem then you should do as you see fit. ... As for the network problem, ...
    (microsoft.public.windowsxp.general)
  • RE: SSL for Exchange stops WSUS
    ... detect your current network configuration settings or you never run CEICW ... configuring ISA Server 2000 as a gateway server, firewall, and web caching ... This newsgroup only focuses on SBS technical issues. ... How you added a certificate to the default web site? ...
    (microsoft.public.windows.server.sbs)