Here is what I was looking for:
static int FreeTcpPort()
{
TcpListener l = new TcpListener(IPAddress.Loopback, 0);
l.Start();
int port = ((IPEndPoint)l.LocalEndpoint).Port;
l.Stop();
return port;
}
More Related Contents:
- How to write a scalable TCP/IP based server
- Get All IP Addresses on Machine
- How can you change Network settings (IP Address, DNS, WINS, Host Name) with code in C#
- In C#, how to check if a TCP port is available?
- Performance Tests of Serializations used by WCF Bindings
- Receiving data in TCP
- How can I install a certificate into the local machine store programmatically using c#?
- TraceRoute and Ping in C#
- How can I ignore a property when serializing using the DataContractSerializer?
- Why re-initiate the DbContext when using the Entity Framework?
- Why method overloading is not allowed in WCF?
- Caching in WCF?
- “Do not use Abstract Base class in Design; but in Modeling/Analysis”
- Broken TCP messages
- Identifying active network interface
- Error 0x80005000 and DirectoryServices
- How to determine MAC Address of the actual physical network card — not virtual network interfaces created by VPN’s (.NET C#)
- Is DataContract attributes required for WCF
- find all ip address in a network
- How to call wcf service Asynchronously
- How can I pass a lambda expression to a WCF service?
- Why does my .NET application crash when run from a network drive?
- Error 5 : Access Denied when starting windows service
- Returning DataTables in WCF/.NET
- System.ServiceModel not found in .NET Core project
- When to change the Generate Serialization Assembly value?
- Client configuration to consume WCF JSON web service
- Does WCF support WS-Security with SOAP 1.1?
- forward traffic from port X to computer B with c# “UDP punch hole into firewall”
- A call to SSPI failed, see inner exception – The Local Security Authority cannot be contacted