Re: Setting size limit of data while reading or writing from sockets
- From: David Schwartz <davids@xxxxxxxxxxxxx>
- Date: Thu, 05 Jul 2007 19:55:46 -0700
On Jul 5, 7:26 pm, "guent...@xxxxxxxxx" <guent...@xxxxxxxxx> wrote:
On Jul 5, 6:44 pm, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:
No, this is incorrect. The size of the receive buffer is *NOT*
guaranteed to be measured in application data bytes.
You're correct: for some underlying protocols, the receive buffer may
include stuff other than application data. Somewhere along the way I
made the mistake of assuming the OP was talking about TCP, in which
case the receive buffer is limited to application data (yes, including
the OOB data, if present), at least that's how I understand the Single
Unix Spec's description of the socket receive queue.
The receive buffer is not limited to application data. And even if it
was, it might well at least need to store whether data is OOB or not,
and there's no particular limit to how many bytes that might or might
not take.
If the transport involved isn't TCP then other rules apply. My
apologies for not qualifying my original statements.
They apply to TCP as well. An application no way of knowing what the
implementation keeps in the receive queue.
It is this simple: Either the application may wait for the stack or
the stack may wait for the application, but not both. Since the stack
may wait for the application, the application may not wait for the
stack. It really is that simple.
2) the application protocol doesn't require an application-level
response before that data can all be sent
Nope.
I can't make sense of what your disagreement with my statement is.
You are assuming that the five bytes of application data will always
fit in the receive buffer and the stack will never refuse to accept
new data when there are fewer than five bytes in the receive buffer.
These are all simply assumptions. They may or may not be true on a
given implementation, the next version of an implementation, or in
some strange corner case with a proxy and a remote Windows client with
a low-memory TCP implementation.
The networking stack has every right to refuse to receive anyNo, it must not stop accepting bytes from the sender if there's
more data until the application receives the data the stack has
already received.
space in the receive buffer.
Why must it not? Did you just make that up?
In the case of TCP (which may not be what the OP is using), I'll cite
Stevens's "UNIX Network Programming, volume 1", section 7.5, wherein
he states:
With TCP, the available room in the socket receive buffer is
the window that TCP advertises to the other end.
Since he has no idea what window TCP advertises to the other end ...
In any event, existing implementations *DO* shrink their windows. This
is bad practice, but it's also bad to break if that happens. So even
if you knew a window size that was advertised at some point, the
window could in fact have shrunk.
DS
.
- Follow-Ups:
- Re: Setting size limit of data while reading or writing from sockets
- From: Rainer Weikusat
- Re: Setting size limit of data while reading or writing from sockets
- References:
- Setting size limit of data while reading or writing from sockets
- From: osmankhalid2005
- Re: Setting size limit of data while reading or writing from sockets
- From: Mark Holland
- Re: Setting size limit of data while reading or writing from sockets
- From: David Schwartz
- Re: Setting size limit of data while reading or writing from sockets
- From: guenther@xxxxxxxxx
- Re: Setting size limit of data while reading or writing from sockets
- From: David Schwartz
- Re: Setting size limit of data while reading or writing from sockets
- From: guenther@xxxxxxxxx
- Setting size limit of data while reading or writing from sockets
- Prev by Date: Re: Setting size limit of data while reading or writing from sockets
- Next by Date: Re: Setting size limit of data while reading or writing from sockets
- Previous by thread: Re: Setting size limit of data while reading or writing from sockets
- Next by thread: Re: Setting size limit of data while reading or writing from sockets
- Index(es):
Relevant Pages
|
Loading