[Haskell-cafe] Interpreting fields in a buffer

Tomasz Zielonka t.zielonka at students.mimuw.edu.pl
Mon Jan 26 13:24:37 EST 2004

On Mon, Jan 26, 2004 at 10:34:06AM +0000, Alastair Reid wrote:
> To access the fields, you will need to write a bunch of functions to read them 
> out (and write them if you need).  There's basically two approaches:
> 1) Write access functions in C and use the ffi interface to call them.
>    For example, you might have a function to read the TTL field given
>    a pointer to the IP header.
> 2) Write access functions in Haskell using functions from the Storable
>    class and associated libraries.

3) Roll your own (de)serialization framework

That's what I did. It's a bit complicated, but I will try to describe it
within a couple of days. Right now all I can say is that it uses TH and
has a couple of implementations of low-lever decoders, one of which
reads directly from UArray Int Word8. I managed to achieve throughput of
3 MB / s for quite complicated binary protocols, and I think I can
improve that even further.

Best regards,

.signature: Too many levels of symbolic links

More information about the Haskell-Cafe mailing list