[Haskell-cafe] Heterogenous network stream

Charles-Pierre Astolfi cpa at crans.org
Sun Oct 17 08:31:47 EDT 2010


Hi cafe,

I'd like to implement a toy-protocol and I'm looking for the sanest
way (for me) to do so.

Here's what it looks like:
The server receives, in that order:
- Ascii string (4 bytes)
- 16 bits int (2 bytes)
- 8 bits int (1 byte)
- UTF8 string (128 bytes)

I tried to use hGetBuf, but I don't know if it's the way to go and I
did not understood what to do with the buf::Ptr a argument. I'm not
very concerned about efficiency.

I don't know how I should convert my 16 and 8 bits int (read as Chars,
I guess) to an Int. Is there something for that in the standard
library?

As I also write the client, I'm looking for a conversion in both ways.

Thanks,
--
Charles-Pierre


More information about the Haskell-Cafe mailing list