sockets (ghc-5.04.1)

Volker Stolz stolz@i2.informatik.rwth-aachen.de
Thu, 16 Jan 2003 15:30:42 +0100


In local.glasgow-haskell-users, you wrote:
> I have a program that uses INET sockets and I wanted to change it to
> use Unix domain sockets. Here is the relevant code:
> 
>   sock <- listenOn portID
>   (h, hostname, portnumber) <- accept sock
> 
> I get an error message when running it with
> portID = UnixSocket "/home/thiemann/.socket"

Somebody decided that Unix sockets are Datagrams in Network.hs,
which is wrong (thanks for finding this bug), they're Stream sockets.

You might want to avoid Network for the time being and use
Network.Sockets, because fixing this will trigger another bug:
Network.accept is currently only designed for Inet-sockets, its type
makes that clear without even resorting to The Source: you cannot get
a host & port from a Unix socket, so while Socket.accept will work,
Network.accept won't and fail on getHostBy*. The getHostBy* would have
to be moved away from accept into listenOn first (Thanks, #2).

I'd vote for removing Unix sockets from Network.hs to avoid this.
(Sockets are already quite well abstracted on Un*x, so that's what
you get for trying to put another layer on top of it #)

Volker
-- 
http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME