[GHC] #2795: The Network.Socket library does not take into
account that the bits in the network are sent as big enddian.
GHC
trac at galois.com
Thu Nov 20 17:48:37 EST 2008
#2795: The Network.Socket library does not take into account that the bits in the
network are sent as big enddian.
-----------------------------------------------------------------------+----
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: libraries/network | Version:
Severity: major | Resolution:
Keywords: socket port number big-enddian little-enddian conflict | Testcase:
Architecture: x86 | Os: Linux
-----------------------------------------------------------------------+----
Comment (by felixmar):
Hi Alejandro and Josef,
This is not a bug, but the documentation for Network.Socket is lacking.
!PortNumber is defined as
{{{
newtype PortNumber = PortNum Word16
}}}
The Word16 argument of !PortNum represents the internal port number of
!PortNumber and is in network byte order. Because !PortNumber is an
instance of Num you can define a !PortNumber value like this:
{{{
let port = 51777 :: PortNumber
}}}
The value 51777 will then be automatically converted to it's internal
representation depending on the little-endianness or big-endianness of the
processor.
Regards,
Felix
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2795#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list