
On 28 June 2004 13:17, Peter Simons wrote:
Simon Marlow writes:
The runtime uses non-blocking I/O and select() internally in order to support multi-threaded I/O. We don't have any direct support for timeouts [...]
Thanks for the clarification. I understand that.
But what would happen if I _do_ set a timeout on the socket level nonetheless? The timeout would strike in form of a read() or write() call returning -1 with an errno of ETIMEDOUT, so clearly it would be noticed by the RTS. The question is: will the RTS report the failure to me through an asynchronous exception?
Because if it does, then that is all the "support" I'll ever need, it saves me from 'forkIO'ing a racer thread for every operation that might time out.
The POSIX spec says that if I/O on a socket times out, then the operation will return EAGAIN or EWOULDBLOCK (there's no ETIMEOUT). It doesn't say what happens to select() on a socket that times out, so I'm not sure what will happen if you try this in GHC. The Linux socket(7) man page seems to say that you can't set SO_RCVTIMEO or SO_SNDTIMEO on Linux (but perhaps you can with a 2.6 kernel?). Cheers, Simon

Simon Marlow writes:
It doesn't say what happens to select() on a socket that times out, so I'm not sure what will happen if you try this in GHC.
Okay, thanks for the information! Looks like a racer thread per timeout is the better approach after all. Peter

Simon Marlow wrote:
The Linux socket(7) man page seems to say that you can't set SO_RCVTIMEO or SO_SNDTIMEO on Linux (but perhaps you can with a 2.6 kernel?).
I suspect that the manual page may be outdated. 2.4 implements those
options; at least, setsockopt stores the value in the "struct sock",
and getsockopt reads it from there, although I haven't checked whether
specific protocols honour those settings.
--
Glynn Clements
participants (3)
-
Glynn Clements
-
Peter Simons
-
Simon Marlow