[Haskell] setSocketOption unusable?

Simon Marlow simonmar at microsoft.com
Thu Oct 13 05:47:37 EDT 2005

[ moved to libraries at haskell.org from haskell at haskell.org]

On 12 October 2005 21:01, John Goerzen wrote:

> I'm wanting to set the SO_RCVTIMEO and SO_SNDTIMEO options on a socket
> from Haskell.  socket(7) say that these take a struct timeval ad a
> parameter.  (Other options, such as SO_LONGER, also could have this
> problem.)
> In Haskell, we see:
> setSocketOption :: Socket -> SocketOption -> Int -> IO ()
> Now, there are SocketOption constructors (RecvTimeOut and SendTimeOut)
> for what I want.  But there is no way to give it a proper timeval (and
> yes, I checked the source.)
> setSocketOption definately wants an Int, and is passing the length of
> the Int to setsockopt(2) as well, so it appears to me that there is
> absolutely no way to correctly specify SO_RCVTIMEO or SO_SNDTIMEO
> through Haskell's socket layer.
> Is that correct?
> If so, how can we fix it?

Looks like that interface is fairly broken to me.  SocketOption should
be an albebraic type with the appropraite parameters to each

Fortunately everything is exported non-abstractly from Network.Socket so
you can implement your own setSocketOption.  If you come up with some
code, I'll incorporate it, or just submit a bug report.


More information about the Libraries mailing list