<div dir="ltr">It seems that hPutBuffNonBlocking flush the buffer and blocks anyway when it has not enough space for the next message. <div><br></div><div><br></div><div><pre style="color:rgb(0,0,0)">    <span class="" style="color:rgb(138,138,138)">-- else, we have to flush</span>
<a name="line-749"></a>        <span class="" style="color:rgb(175,0,95)">else</span> <span class="" style="color:rgb(175,0,95)">do</span> <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/src/GHC.IO.Handle.Internals.html#debugIO" class="" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="" style="color:rgb(7,54,66)">debugIO</span></a> <span class="" style="color:rgb(203,75,22)">"hPutBuf: flushing first"</span>
<a name="line-750"></a>                <a name="local-1627606595"></a><a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/src/GHC.IO.Handle.Text.html#local-1627606595" class="" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="" style="color:rgb(7,54,66)">old_buf'</span></a> <span class="" style="color:rgb(220,50,47)"><-</span> <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/src/GHC.IO.BufferedIO.html#flushWriteBuffer" class="" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="" style="color:rgb(7,54,66)">Buffered</span><span class="" style="color:rgb(211,54,130)">.</span><span class="" style="color:rgb(7,54,66)">flushWriteBuffer</span></a> <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/src/GHC.IO.Handle.Text.html#local-1627606575" class="" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="" style="color:rgb(7,54,66)">haDevice</span></a> <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/src/GHC.IO.Handle.Text.html#local-1627606591" class="" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)"><span class="" style="color:rgb(7,54,66)">old_buf</span></a>
<a name="line-751"></a>                        <span class="" style="color:rgb(138,138,138)">-- TODO: we should do a non-blocking flush here</span></pre><pre style="color:rgb(0,0,0)"><span class="" style="color:rgb(138,138,138)"><br></span></pre><a href="https://tldrify.com/bga">https://tldrify.com/bga</a></div><div><br></div><div>this should be a bug or a feature not implemented. </div><div><br></div><div>since the flush uses <span class="" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213);color:rgb(7,54,66)"><a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/src/GHC.IO.BufferedIO.html#flushWriteBuffer" class="" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213)">flushWriteBuffer</a>, that</span> blocks,  hPutBuffNonBlocking does the same than hPutBuff and the buffer congestion can not be detected.</div><div><br>I will try to do a new version with <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/src/GHC.IO.BufferedIO.html#flushWriteBuffer0" class="" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,232,213);background-color:rgb(238,232,213)"><span class="" style="color:rgb(7,54,66)">flushWriteBuffer0</span></a><span style="color:rgb(7,54,66)">  which do not blocks.</span><br><span style="color:rgb(0,0,0)"></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-09-17 15:41 GMT+02:00 james <span dir="ltr"><<a href="mailto:james@mansionfamily.plus.com" target="_blank">james@mansionfamily.plus.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 17/09/2015 13:52, Brandon Allbery wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
...<span class=""><br>
It is possible that recent network package changed this, but in the past *all* socket operations had to be under the aegis of *one* withSocketsDo, otherwise any handles, buffers, etc. would become invalid when Winsock was deinitialized.<br>
</span></blockquote>
<br>
See <a href="http://neilmitchell.blogspot.co.uk/2015/02/making-withsocketsdo-unnecessary.html" rel="noreferrer" target="_blank">http://neilmitchell.blogspot.co.uk/2015/02/making-withsocketsdo-unnecessary.html</a><br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Alberto.</div>
</div>