
A related problem... connections are refused when using accept if the hostname doesn't resolve. Maybe something like this would help, unless there is a better way?
accept sock = do ~(sock', (SockAddrInet port haddr)) <- Socket.accept sock (HostEntry peer _ _ _) <- ((getHostByAddr AF_INET haddr) `Control.Exception.catch` (\_ -> return (HostEntry ((showHex ((haddr `shiftR` 24) .&. 0xff) . showChar '.' . showHex ((haddr `shiftR` 16) .&. 0xff) . showChar '.' . showHex ((haddr `shiftR` 8) .&. 0xff) . showChar '.' . showHex (haddr .&. 0xff)) "") [] AF_INET []))) handle <- socketToHandle sock' ReadWriteMode return (handle, peer, port)
Yes, except that inet_ntoa is the right way to get the string representation of an IP address. I'll make this change. Cheers, Simon