<div dir="ltr">On Tue, Sep 3, 2013 at 6:56 PM, Simon Yarde <span dir="ltr">&lt;<a href="mailto:simonyarde@me.com" target="_blank">simonyarde@me.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I&#39;ve found that setting the send buffer size causes send to truncate the ByteString to the buffer size, but that successive sends continue to succeed when the buffer should be full.<br>
</blockquote><div><br></div><div>I see no actual flow control here. That the receiver is blocked does not mean the receiver&#39;s *kernel* has not received the packets and buffered them. Also note that send is not synchronous; it cannot know that the receiver has hit its buffer limit --- and the kernel may well have already sent the previous packet, so the send buffer is in fact empty at that point, with the pending packet either in flight or in the receiving kernel&#39;s (interrupt time or normal; they are usually distinct. Or, with a sufficiently fancy network card, its own) network buffers.<br>
</div><div><br></div><div>In short, you have not thought through all the possible ramifications, nor considered that the kernel handles packets and buffering independently of your program, nor considered the effects of the non-instantaneous network between sender and receiver. It may or not behave differently when sender and receiver are on the same machine. Do not assume that the kernel will short-circuit here and leave out all the intermediate buffering! The only part you&#39;re guaranteed to avoid is the interface with the network hardware.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">The crux of my line of enquiry is this;  how can my application know when to pause in generating its chunked output if send doesn&#39;t block and the current non-blocking send behaviour apparently succeeds when the send buffer should be full?<br>
</blockquote><div><br></div><div>I would suggest reading a book on TCP/IP networking.</div><div><br></div></div>-- <br><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div>
<div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div>
</div>
</div></div>