[Mono-list] Re: Fail to set socket send&receive timeout!

Dick Porter dick at ximian.com
Mon Dec 19 11:46:33 EST 2005


On Mon, 2005-12-19 at 16:14 +0100, Robert Jordan wrote:
> li wrote:
> > hello sir,
> > With your advice I update my redhat9 to fedral4(kernel 2.6.11), but the socket 
> > still can't be set timeout property. What is wrong with it? And I also have a 
> > problem with Process.GetProcesses(), it can't get all processes in current machine.

Running your example code on suse 9.3 I get:

CommServ is listening...

Unhandled Exception: System.Net.Sockets.SocketException: Operation on
non-blocking socket would block
in <0x001a4> System.Net.Sockets.Socket:Accept ()
in <0x0010d> CommTest.Class1:Main (System.String[] args)

which is after the SetSocketOption() calls.  The error message there is
slightly misleading, because EGAIN and EWOULDBLOCK mean the same thing
to accept (2).  The accept is timing out after a second, and returning
EAGAIN because there are no connections present to be accepted.  If I
telnet to the listening port in that second, your test gets as far as:

Unhandled Exception: System.Net.Sockets.SocketException: Operation on
non-blocking socket would block
in <0x0006d> System.Net.Sockets.Socket:Receive_nochecks (System.Byte[]
buf, Int32 offset, Int32 size, SocketFlags flags)
in <0x00034> System.Net.Sockets.Socket:Receive (System.Byte[] buf)
in <0x0015d> CommTest.Class1:Main (System.String[] args)

if I don't type anything in time (ie, the 1 second timeout.)  If I'm
quick enough it lists the other mono processes I have running.

I regard that as working.


> 
> Process.GetProcesses () returns only processes
> which has been started by your application,
> including the application itself. This is
> how GetProcesses () can be implemented under
> unix.

Not quite.  It lists processes started by any other mono application
running with your user ID.  Though because of the parent/child
relationship with unix processes a process can only wait for its own
children to exit.

- Dick




More information about the Mono-list mailing list