listen/bind socket problem in GHC 5.04
Simon Marlow
simonmar@microsoft.com
Tue, 20 Aug 2002 10:05:40 +0100
> I understand that GHC 5.04 has reoganized the network modules,=20
> but somehow my code broke over GHC 5.04...=20
>=20
> prepareSocket addr port =3D do
> s <- socket AF_INET Stream 6
> setSocketOption s ReuseAddr 1
> let port' =3D PortNum port
> addr' <- case addr of
> Just str -> inet_addr str >>=3D (\x -> return=20
> (SockAddrInet port' x))
> Nothing -> return (SockAddrInet port' iNADDR_ANY)
> bindSocket s addr'
> listen s 2
> return s
instead of=20
let port' =3D PortNum port
use
let port' =3D fromIntegral port
The PortNumber type should really be abstract. Internally, it is stored
in network byte order, but you bypassed the conversion to network byte
order by constructing a value of type PortNumber directly.
Cheers,
Simon