20 Aug
2002
20 Aug
'02
9:05 a.m.
I understand that GHC 5.04 has reoganized the network modules, but somehow my code broke over GHC 5.04...
prepareSocket addr port = do s <- socket AF_INET Stream 6 setSocketOption s ReuseAddr 1 let port' = PortNum port addr' <- case addr of Just str -> inet_addr str >>= (\x -> return (SockAddrInet port' x)) Nothing -> return (SockAddrInet port' iNADDR_ANY) bindSocket s addr' listen s 2 return s
instead of let port' = PortNum port use let port' = 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