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

Gonzalo Paniagua Javier gonzalo at ximian.com
Wed Dec 21 22:40:56 EST 2005

On Mon, 2005-12-19 at 18:47 +0800, 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.
> Would you do me a favor to help me again please? Thank you very much!
> Here is the source code:
> using System;
> using System.Net.Sockets;
> using System.Net;
> using System.Runtime.InteropServices;
> using System.IO;
> using System.Diagnostics;
> namespace CommTest
> {
> 	class Class1
> 	{
> 		[STAThread]
> 		static void Main(string[] args)
> 		{
> 			//it can't work in fedral core 4(kernel 2.6.11),but works well in winXP
> 			Socket TCPSocket=new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
> 			//following 2 functions cause a exception:non-block socket would block
> 			TCPSocket.SetSocketOption(SocketOptionLevel.Socket,SocketOptionName.SendTimeout,1000);
> 			TCPSocket.SetSocketOption(SocketOptionLevel.Socket,SocketOptionName.ReceiveTimeout,1000);

You have to Connect() or Accept() before setting the timeout.


More information about the Mono-list mailing list