[Mono-devel-list] Socket Send/ReceiveTimeouts
avd at openlinksw.com
Thu Apr 3 08:57:53 EST 2003
Matthias Sessler wrote:
> The second option would be to only abort the thread which is waiting for
> the send/receive. Is this possible with mono? The ms framework would
> abort the thread after send/receive method would return.
I don't think there's any need for timers, threads and such. There is
very wonderful poll method which does the trick quite well. At the
application level you could write something like this:
if (false == socket.Poll (microSeconds, SelectMode.SelectRead))
throw new Exception ();
As compared to the use of timeout socket option (when it's actually
supported) this has only slight disadvantage that you have two system
calls per a read instead of one. This might matter only for very busy
server applications which probably would use select anyway for i/o
multiplexing and most likely would be written in C :).
If you really want to fix the problem at the Mono level, I think
the best way for this is to change the SetSocketOption_internal,
Receive_internal, and Send_internal methods in the following way:
- SetSocketOption_internal calls setsockopt() for SO_RCVTIMEO
and SO_SNDTIMEO options in case they are supported by the system,
otherwise store them somewhere.
- In case timeout options are supported Receive_internal/Send_internal
call recv()/send() immediately, otherwise if a timeout option was set
first call select() and throw an exception in case of timeout.
> Does anyone know how java does this on linux?
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list