RE: listen/bind socket problem in GHC 5.04

2002-08-20 Thread Simon Marlow


 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
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell



Re: listen/bind socket problem in GHC 5.04

2002-08-20 Thread paul

Thanks for the help, it works! I wonder why mkPortNumber is
no longer in the socket API?

Regards,
.paul.

On Tue, Aug 20, 2002 at 10:05:40AM +0100, Simon Marlow wrote:
 
 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
 ___
 Haskell mailing list
 [EMAIL PROTECTED]
 http://www.haskell.org/mailman/listinfo/haskell
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell