Hi,


I have a question related to a program I'm writing. I have to handle IP packets,
which will be read into a buffer. What is the best haskell idiom for getting access
to the fields in the buffer?


The IP header has a number of fixed format fields. In C, I would define a struct,
then cast the pointer to the beginning of the buffer to a pointer to the struct. I would then be
able to access each field in the header as <packet_struct_ptr> -> <field>.


Is there a way in haskell to declare the format of the header, then access the
components of the buffer as elements of those types? I'm only going to do read
access on the buffer (an unboxed array). Most fields won't be examined but I can't
tell in advance which ones will have to be looked at.


I've not seen an example of this kind and was wondering if this was
especially awkward.

Thanks.

Best Wishes,
Greg

Gregory Wright
Antiope Associates LLC
18 Clay Street
Fair Haven, New Jersey 07704

[EMAIL PROTECTED]

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to