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