TcpListener Constructor (IPEndPoint)
Initializes a new instance of the TcpListener class with the specified local endpoint.
Assembly: System (in System.dll)
localEP is a null reference (Nothing in Visual Basic).
This constructor allows you to specify the local IP address and port number on which to listen for incoming connection attempts. Before using this constructor, you must create an IPEndPoint using the desired local IP address and port number. Pass this IPEndPoint to the constructor as the localEP parameter.
If you do not care which local address is assigned, you can create an IPEndPoint using IPAddress.Any as the address parameter, and the underlying service provider will assign the most appropriate network address. This might help simplify your application if you have multiple network interfaces. If you do not care which local port is used, you can create an IPEndPoint using 0 for the port number. In this case, the service provider will assign an available port number between 1024 and 5000. If you use this approach, you can discover what local network address and port number has been assigned by using the LocalEndpoint property.
Call the Start method to begin listening for incoming connection attempts.
This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.