[Haskell-cafe] Simple network client

Timo B. Hübel t.h at gmx.info
Wed Jan 30 08:06:07 EST 2008


On Wednesday 30 January 2008 13:51:58 you wrote:
> > Okay, but then I have to make sure that my strings won't contain any
> > newline characters, right? If this is the case, another question raises
> > up: I am using Data.Binary to do the serialization of my data structures
> > to ByteString, so does anybody know if this makes guarantees about
> > newline characters in the resulting ByteString?
> > Otherwise I would go for the "transmit the length of what to
> > expect"-solution.
>
> Fortunately there is an easy way to hide newlines.
>
> Use "show"
>
> That will wrap newlines as \n, as well as coping with other odd
> characters like NULL which might upset a C library (if you're talking to
> C at any point).
>
> Then you use "read" on the far end.

This sounds good, but don't I throw away all (possible) performance gains of 
transmitting ByteStrings directly when using show/read to convert them to 
ordinary strings and back?

Thanks,
Timo


More information about the Haskell-Cafe mailing list