[Mono-bugs] [Bug 72034][Cri] New - Cannot bind Socket (or TcpListener) to IPv6 and IPv4 on the same port at the same time

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 31 Jan 2005 21:25:54 -0500 (EST)


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 eric@extremeboredom.net.

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

--- shadow/72034	2005-01-31 21:25:54.000000000 -0500
+++ shadow/72034.tmp.7818	2005-01-31 21:25:54.000000000 -0500
@@ -0,0 +1,57 @@
+Bug#: 72034
+Product: Mono: Class Libraries
+Version: 1.0
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Critical
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: eric@extremeboredom.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Cannot bind Socket (or TcpListener) to IPv6 and IPv4 on the same port at the same time
+
+The following code works correctly (verified using netstat) on Windows XP
+using the latest version of the .NET Framework but throws an "Address
+already in use" exception when executed with mono:
+
+-- 
+
+using System;
+using System.Net;
+using System.Net.Sockets;
+
+public class IPv6Test {
+        public static void Main() {
+                TcpListener ipv6Listen = new TcpListener(IPAddress.IPv6Any,
+4242);
+                ipv6Listen.Start();
+                Console.WriteLine("IPv6 Listening!");
+
+
+                TcpListener ipv4Listen = new TcpListener(IPAddress.Any, 4242);
+                ipv4Listen.Start();
+                Console.WriteLine("IPv4 Listening!");
+
+
+                while (true)
+                        Console.ReadLine();
+        }
+}
+
+--
+
+$ ./IPv6Test.exe
+IPv6 Listening!
+
+Unhandled Exception: System.Net.Sockets.SocketException: Address already in use
+in <0x000de> System.Net.Sockets.Socket:Bind (System.Net.EndPoint)
+in <0x00050> System.Net.Sockets.TcpListener:Start ()
+in <0x00087> IPv6Test:Main ()
+
+--