Home › Forums › Support › Unable to create a TCP connection › Reply To: Unable to create a TCP connection
		January 8, 2014 at 16:45
		
		#1399
		
		
		
	
Inactive
		
		
	Heyup Guys,
Many thanks for the help msdc123. The following code is correct for listening on port 10000:
TCPConnection.StartListening(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10000));
but it is important to know that if port 10000 is unavailable, NetworkComms.Net will automatically fail over to a random port. If a port is unavailable and you would rather have an exception when calling TCPConnection.StartListening.
The solution is to check which port was used on the server:
Console.WriteLine("Listening for messages on:");
foreach (System.Net.IPEndPoint localEndPoint in Connection.ExistingLocalListenEndPoints(ConnectionType.TCP)) 
    Console.WriteLine("{0}:{1}", localEndPoint.Address, localEndPoint.Port);
Once you have confirmed the correct listening port, if you still have problems, please post back.
Regards,
Marc
