[Mono-bugs] [Bug 52759][Blo] New - TcpListener fails to generate a port # when 0 passed to the constructor

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 12 Jan 2004 02:45:55 -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 gregt@artistech.com.

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

--- shadow/52759	2004-01-12 02:45:55.000000000 -0500
+++ shadow/52759.tmp.20495	2004-01-12 02:45:55.000000000 -0500
@@ -0,0 +1,71 @@
+Bug#: 52759
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: Windows XP SP1
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Blocker
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: gregt@artistech.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: TcpListener fails to generate a port # when 0 passed to the constructor
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+TcpListener fails to generate a port # when 0 passed to the constructor. 
+The following is in the .Net documentation for TcpListener 
+constructor: "If you do not care which local port is used, you can 
+specify 0 for the port number. In this case, the service provider will 
+assign an available port number between 1024 and 5000." The code sample 
+below works in both .Net 1.0 and 1.1.
+
+Steps to reproduce the problem:
+Compile and execute the following code:
+
+using System;
+using System.Net;
+using System.Net.Sockets;
+
+class ConsoleApp
+{
+	[STAThread]
+	static void Main(string[] args)
+	{
+		TcpListener server = null;
+
+		IPEndPoint endp;
+
+		//ip address of the connection
+		IPHostEntry thisHost = Dns.Resolve(Dns.GetHostName());
+		IPAddress addr = thisHost.AddressList[0];
+		server = new TcpListener(addr, 0);
+			
+		//start listening
+		server.Start();
+
+		endp = (IPEndPoint) server.LocalEndpoint;
+		Console.WriteLine("address=" + endp.Address.ToString() 
++ " port=" + endp.Port.ToString());
+
+	}
+}
+
+Actual Results:
+port=0
+
+Expected Results:
+port # should be from 1024 to 5000.
+
+
+How often does this happen? 
+Always.
+
+Additional Information:
+
+Currently using Mono 0.29 on Windows XP SP1.