Haskell network
s HostAddress
says "network byte order" in it's Documentation
However, if I 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 this expected? Why it's printing things little-endian? Should I pass IP address in big or little endian format?
It looks like the common way to generate IPv4 addresses is to use Socket.inet_addr
, e.g.:
do x <- inet_addr "192.0.0.0"; return $ SockAddrInet 50 x
Or, equivalently:
inet_addr "192.0.0.0" >>= (return . SockAddrInet 50)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With