[Haskell-beginners] Q) Using Data.Binary to parse a packet

Bjoern Brandenburg bbb.lst at gmail.com
Tue Jul 28 22:44:00 EDT 2009


2009/7/28 Yang, Chul-Woong <cwyang at aranetworks.com>:
> *** Exception: too few bytes. Failed reading at byte position 9
> *Main>
>
> Why and what can I do for this? Thanks in advance.

The Get monad is complaining that you are trying to read more than 8
bytes from a buffer of length 8. Presumably you are sending packets of
that size?

If you want to handle such errors (and you should), you could either
first test the length of the incoming message or use exception
handling to catch the exception in myHandler.

- Björn


More information about the Beginners mailing list