<div class="gmail_quote">Thanks  Henning ,<br>
<br>
I finally found the problem and an elegant solution (I guess)<br>
<br>
The problem is not, as I feared, the coalescence of bytestring chunks<br>
in more bigger chunks, but the buffering mode of the stream.  The<br>
stream simply waits until the buffer is full to stream its content.<br>
<br>
So the solution is either to change the blocking to NoBlocking (with<br>
hSetBuffering, and very inefficient) or else to modify<br>
Data.BytreString.Lazy.hPut  to insert an hFlush after each chunk<br>
delivered to the stream:<br>
<br>
<br>
import qualified Data.ByteString as S(hPut)<br>
import  Data.ByteString.Lazy.Internal(foldrChunks)<br>
<br>
    myhPut :: Handle →  ByteString →  IO ()<br>
    myhPut h cs = foldrChunks (λc rest →  S.hPut h c &gt;&gt;<br>
System.IO.hFlush h &gt;&gt; rest) (return ()) cs<br>
<br>
<br>
the original Data.BytreString.Lazy.hPut  has not the hFlush step.<br>
<br>
<br>
I had to modify simpleServer to do that and now I control exactly the<br>
size of the fragment and the moment when it is delivered, because  the<br>
mappend instance of ByteString.Lazy respect the chunks created with<br>
&quot;pack (String)&quot;.<br>
<br>
I give it to the consideration of the maintainers of<br>
Data.ByteString.Lazy (Dons),, because lazy bytestrings, since are a<br>
concatenation of user made blocks,  have such possibility of<br>
controlling precise streaming. Something that neither ordinary strings<br>
nor strict bytestring, and I guess nothing else has. Don´t miss out<br>
this!.<br>
<br>
<br>
2010/7/27, Henning Thielemann &lt;<a href="mailto:lemming@henning-thielemann.de">lemming@henning-thielemann.de</a>&gt;:<br>
<div><div></div><div class="h5">&gt;<br>
&gt; On Tue, 27 Jul 2010, Alberto G. Corona wrote:<br>
&gt;<br>
&gt;&gt; The question is:  are there some way to control bytestring streaming?.<br>
&gt;&gt; Can It be done without the stream handler?<br>
&gt;<br>
&gt; I think there is a function that converts a lazy ByteString to a list of<br>
&gt; strict ByteStrings, that should work without copying the chunk data<br>
&gt; around. On this chunk list you can do all kind of manipulations, like<br>
&gt; merging adjacent small chunks.<br>
&gt;<br>
</div></div></div><br>