Dedicated network port in C #
How can I ensure that a particular port on my computer is not being used for any other purpose other than the service I need in C #?
In my lan-messenger simulator I am getting a denied error when trying to connect to a remote host. I need to somehow make sure the port is not being used for any other purpose.
0
a source to share
3 answers
IPAddress localAddr = IPAddress.Parse("127.0.0.1");
server = new TcpListener(localAddr, 0);
This will give you the first available port on the local machine.
http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx
+1
a source to share