Please do not reply to this email- if you want to comment on the bug, go to the URL shown below and enter your comments there.
Changed by [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=79352 --- shadow/79352 2006-09-11 06:41:30.000000000 -0400 +++ shadow/79352.tmp.22435 2006-09-11 06:41:30.000000000 -0400 @@ -0,0 +1,137 @@ +Bug#: 79352 +Product: Mono: Class Libraries +Version: 1.0 +OS: Debian Woody +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Wishlist +Component: System +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: Problem with Socket.Poll method + +Description of Problem: + +I try to check connection to the host during the specified timeout. The +Socket.Poll return true for the IP 1.1.1.1, timeout 5 seconds and +SelectMode.SelectWrite parameter. The sample compiled mcs and executed +under .Net Framework works fine. Mono 1.1.13, Debian Linux, VMWare 4.5. + +Steps to reproduce the problem: +1. + +using System; +using System.Net; +using System.Net.Sockets; +using System.Collections; + +namespace ConsoleApplication1 +{ + /// <summary> + /// Summary description for Class1. + /// </summary> + /// + + class Class1 + { + /// <summary> + /// The main entry point for the application. + /// </summary> + [STAThread] + static void Main(string[] args) + { + // + // TODO: Add code to start application here + // + + DateTime start = DateTime.Now; + + try + { + CheckConnection("1.1.1.1", 8080, 5); + } + catch(Exception) + { + Console.Out.WriteLine("Test succeeded: " + +DateTime.Now.Subtract(start).TotalSeconds.ToString() + " seconds"); + return; + } + + Console.Out.WriteLine("Test failed: " + DateTime.Now. +Subtract(start).TotalSeconds.ToString() + " seconds"); + return; + } + + public static void CheckConnection(string host, int port, int +timeout) + { + using(Socket sock = new Socket(AddressFamily. +InterNetwork, SocketType.Stream, ProtocolType.Tcp)) + { + bool isConnected = false; + + IPHostEntry entries = Dns.GetHostByName(host); + foreach (IPAddress ipAddr in entries.AddressList) + { + sock.Blocking = false; + try + { + sock.Connect(new IPEndPoint(ipAddr, +port)); + } + catch (SocketException ex) + { + Console.Out.WriteLine(ex.ErrorCode. +ToString()); + // ignore errors: + // Resource temporarily unavailable. + // Operation now in progress. + if (ex.ErrorCode != 10035 && ex. +ErrorCode != 10036) + throw; + + } + + isConnected = sock.Poll(timeout * 1000000, +SelectMode.SelectWrite); + Console.Out.WriteLine(ipAddr.ToString() + ":" ++ isConnected.ToString()); + + if (isConnected) + break; + } + + if (!isConnected) + throw new Exception(); + } + } + } +} + +Actual Results: + +10035 +1.1.1.1:True +Test failed: 0.187176 seconds + +Expected Results: + +This code is working fine on .Net framework with the following output: + +10035 +1.1.1.1:False +Test succeeded: 5,035739 seconds + +How often does this happen? + +Very often (sometimes this test is passed well) + +Additional Information: + +Debian is running under VMWare 4.5 _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
