Data.Binary hanging when used with socket - feature?

I'm using the 0.5.1.0 binary package (i.e. Data.Binary/Data.Binary.Get) to encode/decode a lazy bytestring. Unfortunately, decode/get are hanging, possibly due to the underlying chunking logic in Data.Binary.Get. The lazy bytestring is being populated from a socket (via "socketTohandle sock ReadWriteMode . hGetContents"). Periodically, encoded data structures are received from the socket. When the encoded data structure happens to end exactly on a chunk boundary, and in my specific case the final encoded item is an Int(64), the Data.Binary.Get.getBytes function wants to force the next chunk to be read into the lazy bytestring before returning the decoded item (see comment in file at line 333 that reads "forces the next chunk before this one is returned"). Unfortunately, since the socket is not yet ready to send anything the call to decode/get hangs. The assumption seems to be that the lazy bytestring isn't populated from a source that can potentially block. Is this reading correct? If so, are there any workarounds? Appreciate any advice - production code.

On Sun, Jun 17, 2012 at 7:40 PM, Paul Brenman
Appreciate any advice - production code.
Don't use lazy bytestrings for I/O -- use enumerator/conduit/pipes and hook
it up to an attoparsec parser instead. Porting code from the Get monad to
attoparsec's Parser monad should be trivial.
G
--
Gregory Collins
participants (2)
-
Gregory Collins
-
Paul Brenman