> This may be related to the answer just given to do with 
> finalizing the 
> Handles, as I have a
> problem with sockets hanging around after a host name resolution has 
> failed (using the simple socket
> library). Having looked at the code I would like to suggest the 
> following change:
> 
> connectTo hostname (PortNumber port) = do
>     proto   <- getProtocolNumber "tcp"
>     sock        <- socket AF_INET Stream proto
>     he     <- getHostByName hostname
>     connect sock (SockAddrInet port (hostAddress he))
>     socketToHandle sock ReadWriteMode
> 
> Should become:
> 
> connectTo hostname (PortNumber port) = do
>     proto   <- getProtocolNumber "tcp"
>     sock        <- socket AF_INET Stream proto
>     (do
>         he     <- getHostByName hostname
>         connect sock (SockAddrInet port (hostAddress he))
>         socketToHandle sock ReadWriteMode) `Exception.catch` 
> (\e -> do 
> sClose sock;throw e)
> 
> Is this a sensible change to make?

Yes, well spotted.  I'll add the exception handler.

Cheers,
        Simon
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to