
On 15 October 2004 19:44, Tomasz Zielonka wrote:
On Fri, Oct 15, 2004 at 04:24:01PM +0200, Peter Simons wrote:
Hi,
I've found myself needing to show a SockAddr type left and right in my code. Is it possible to add the appropriate definition to Network.Socket? Here is a suggestion:
-- |Split up an 32-bit word in network byte order.
ha2tpl :: HostAddress -> (Int, Int, Int, Int) ha2tpl n = let (b1,n1) = (n .&. 255, n `shiftR` 8) (b2,n2) = (n1 .&. 255, n1 `shiftR` 8) (b3,n3) = (n2 .&. 255, n2 `shiftR` 8) b4 = n3 .&. 255 in (fromEnum b1, fromEnum b2, fromEnum b3, fromEnum b4)
This won't work on big-endian architectures.
If someone has code for a version that works on both endians, now is the time to send it so we can get it into GHC 6.4. Cheers, Simon