[Haskell-cafe] Network.Socket Woes

donnie Jones donnie at darthik.com
Fri Mar 7 13:25:59 EST 2008


Hello Adam,

Maybe you could use the binary package [1] to always encode the portNumber,
etc. in network byte order?  Such as available put/get functions:
putWord16be :: Word16 -> Put

Hope this helps...
__
Donnie

1. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-0.4.1


On 3/7/08, Adam Langley <agl at imperialviolet.org> wrote:
>
> On Fri, Mar 7, 2008 at 8:10 AM, Scott Bell <sebell at gmail.com> wrote:
> >  my test program. The Haskell version, however, does not
> >  return from recvFrom. I've also tried wrapping this in a
> >  withSocketsDo, with no effect.
>
>
> So this is a long standing, ah, issue with the Network modules.
>
> Try sending a UDP packet to port 45607 and you'll find that the
> Haskell code gets it.
>
> hex(45607) = 0xb227
> 0x27b2 = 10162
>
> In short, PortNum doesn't do the endian conversion for you. And I
> don't know a good way to figure out the endianness of the underlying
> system from Haskell I'm afraid. I usually end up FFIing out to htons
> or just assuming that the system is little-endian.
>
> We should really fix this unless there's some trick that I've been
> missing all this time.
>
>
> AGL
>
>
> --
> Adam Langley agl at imperialviolet.org http://www.imperialviolet.org
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080307/3fbc3949/attachment.htm


More information about the Haskell-Cafe mailing list