
By the way, I happen to have a little problem when I try to add data
compression/decompression.
Since its impossible to add binary treatments (I call binary treatment a
function which type is: ByteString -> ByteString, e.g. compression), I made
my own package binary-communicator. (can be found on hackage)
It's very simple. It's a mere IORef containing a lazy bytestring, and
updated when we try to read from it.
Same example, client sends a computation, the server does it and sends the
result back.
When I use "id" a treatment function (no compression whatsoever), everything
works
But when I use compress/decompress (from Codec.Compression.GZip), I have the
following weird issue:
The server treats well the first computation, and sends back the answer, and
then immediately fails with a "Server: too few bytes. Failed reading at byte
position 1", and closes the connection.
GZip compression is supposed to work on lazy bytestrings, and it does since
the first computation is well done.
Does someone see the problem?
I enclosed an archive containing all the files. (working version of
binary-communicator and the sample)
2010/4/8 Gregory Crosswhite
That sounds like a reasonable modification; if you want, free to fork it at http://github.com/gcross/binary-protocol and push me your proposed changes.
Cheers, Greg
On Apr 8, 2010, at 9:12 AM, Yves Parès wrote:
By the way, Gregory, concerning the package binary-protocol, I was
wondering
if it was possible to turn the BinaryProtocol monad from type BinaryProtocol = StateT (Handle, Handle, ByteString) IO to: type BinaryProtocol = StateT (Handle, Handle, ByteString)
And then the functions, like runProtocol, would become: runProtocol :: (MonadIO m) => BinaryProtocol m a -> Handle -> Handle -> m a
I mean that BinaryProtocol could run within any MonadIO, not only IO. This would turn the BinaryProtocol into a monad trans, which would be more generic (we could for instance stack two BinaryProtocols).
Yves Parès wrote:
Problem tracked!
It comes from the last version of bytestring package. I tried with bytestring-0.9.1.5, and it works perfectly.
Do you know where I should submit this bug?
----- Yves Parès
Live long and prosper -- View this message in context: http://old.nabble.com/Simple-binary-protocol-through-network-test-tp28157883... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe