[Mono-bugs] [Bug 74785][Nor] New - Socket.Accept() blocks program termination on Windows

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 1 May 2005 13:41:27 -0400 (EDT)


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 atsushi@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=74785

--- shadow/74785	2005-05-01 13:41:27.000000000 -0400
+++ shadow/74785.tmp.32440	2005-05-01 13:41:27.000000000 -0400
@@ -0,0 +1,60 @@
+Bug#: 74785
+Product: Mono: Class Libraries
+Version: 1.1
+OS: Windows XP
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: atsushi@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Socket.Accept() blocks program termination on Windows
+
+Under mono on Windows, it looks like Socket.Accept() or its internals
+prevents applicatoin from exiting. The example code below successfully
+quits under MS.NET and mono on Linux. Maybe thread blocking?
+
+using System;
+using System.Threading;
+using System.Net;
+using System.Net.Sockets;
+
+class C {
+  public static void Service () {
+    Socket listener = new Socket (AddressFamily.InterNetwork,
+SocketType.Stream, ProtocolType.Tcp);
+    IPEndPoint ep = new IPEndPoint (IPAddress.Any, 50000);
+    listener.Bind (ep);
+    listener.Listen (5);
+
+    while (true) {
+      Socket s = listener.Accept ();
+      Thread.Sleep (500);
+      s.Close ();
+    }
+  }
+
+  public static void Main () {
+    Thread t = new Thread (Service);
+    t.IsBackground = true;
+    t.Start ();
+
+    Thread.Sleep (3000);
+    Console.WriteLine ("Quit.");
+  }
+}
+
+Actual Results:
+no response
+
+Expected Results:
+Print "Quit." and return back to the console.
+
+How often does this happen? 
+Consistently.