Re: preventing data from being mangled

From: David Schwartz (davids_at_webmaster.com)
Date: 11/14/03


Date: Fri, 14 Nov 2003 00:39:59 -0800


"Corey Murtagh" <emonk@slingshot.co.nz.no.uce> wrote in message
news:1068784385.758069@radsrv1.tranzpeer.net...

> Personally I just find it simpler to transfer the remainder into a
> string that I can append to next time through the loop. Depending on
> how you do it, and how often, it shouldn't be terribly inefficient. The
> bigger the buffer the better though, since you want to eliminate as many
> part-message copies, and as few part-reads, as possible.

> Of course if the string class in inefficient, my way will suck arse
> compared to than yours :)

    I would suspect your way is likely to be less efficient than mine, but
the inefficiency would be in an infrequently used code path. Most of the
time, the data you read will consist of some number of complete lines.

    You may be surprised to find that the buffer size doesn't significantly
affect the number of part reads. Generally the client outpaces the server
(since it has little else to do) and the network is slower than either
(assuming the server isn't on the same LAN as the client). So the program
will wind up receiving data roughly in chunks the same size as the packets
flowing over the network, assuming the buffer exceeds the MTU.

    In the rare case where the client doesn't get back to calling read or
receive for two packets, the buffer size won't matter so long as it's at
least twice the MTU. 4Kb is more than twice the typical MTU for ethernet. So
an 64Kb buffer won't receive more data than a 4Kb buffer unless you don't
get around to calling read/recv for the time it takes 3 packets to traverse
the network.

    DS



Relevant Pages

  • Re: preventing data from being mangled
    ... > how you do it, and how often, it shouldn't be terribly inefficient. ... will wind up receiving data roughly in chunks the same size as the packets ... assuming the buffer exceeds the MTU. ...
    (comp.programming)
  • Re: Updating our TCP and socket sysctl values...
    ... remove the buffer bloat issue for tcp transmit buffers. ... Edge routers and other routers in the infrastructure have huge ... verses having to do it for 50 packets of backlog per connection. ... colocated boxes with tons of bw, and servers running out of the house ...
    (freebsd-arch)
  • Re: In-tree version of new FireWire drivers available
    ... Just to recap, the dual buffer receive mode, as described in section ... quadlet aligned amount of header data can be appended into one buffer ... *either* the header buffer or the payload buffer fills up. ... enough to hold headers for all the packets it takes to fill up the ...
    (Linux-Kernel)
  • Re: Deaf CAsyncSocket on Windows Service.
    ... To read them out I need a buffer to ... Short packets at the sender are coalesced into longer packets. ... THe receiver says "I have this much buffer space" and the sender is free to send ... You get an OnReceive notification if there is input data to be read. ...
    (microsoft.public.vc.mfc)
  • Re: Cisco 7204VXR Interface ignored packet
    ... Input queue drops (ignored packets) are usually due to buffers not being ... The buffer defaults are good 98% of the ... 256 max cache size, 256 in cache ... 22496866 hits in cache, 0 misses in cache ...
    (comp.dcom.sys.cisco)