Saturday, 15 February 2014

Haskell network SockAddrInet which endianness to use? -



Haskell network SockAddrInet which endianness to use? -

haskell networks hostaddress says "network byte order" in it's documentation

however, if pass address in network byte order(big-endian), it's show instance prints wrong address:

prelude network.socket> :m + network.socket data.bits prelude network.socket data.bits> sockaddrinet (frominteger 50) (192 `shiftl` 24) 0.0.0.192:50 prelude network.socket data.bits>

is expected? why it's printing things little-endian? should pass ip address in big or little endian format?

it looks mutual way generate ipv4 addresses utilize socket.inet_addr, e.g.:

do x <- inet_addr "192.0.0.0"; homecoming $ sockaddrinet 50 x

or, equivalently:

inet_addr "192.0.0.0" >>= (return . sockaddrinet 50)

haskell network-programming ip

No comments:

Post a Comment