Class TcpListener
Listens for connections from TCP network clients.
public class TcpListener
- Inheritance
-
TcpListener
- Inherited Members
- Extension Methods
Constructors
TcpListener(IPAddress, int)
Initializes a new instance of the TcpListener class that listens for incoming connection attempts on the specified local IP address and port number.
public TcpListener(IPAddress localaddr, int port)
Parameters
localaddr
IPAddressAn IPAddress that represents the local IP address.
port
intThe port on which to listen for incoming connection attempts.
TcpListener(IPEndPoint)
Initializes a new instance of the TcpListener class that listens for incoming connection attempts with the specified endpoint.
public TcpListener(IPEndPoint localEP)
Parameters
localEP
IPEndPointAn IPEndPoint that represents the local endpoint to which to bind the listener Socket.
Properties
Active
Gets a value that indicates whether TcpListener is actively listening for client connections.
protected bool Active { get; }
Property Value
LocalEndpoint
Gets the underlying EndPoint of the current TcpListener.
public EndPoint LocalEndpoint { get; }
Property Value
Server
Gets the underlying network Socket.
public Socket Server { get; }
Property Value
Methods
AcceptSocket()
Accepts a pending connection request.
public Socket AcceptSocket()
Returns
- Socket
A Socket used to send and receive data.
AcceptTcpClient()
Accepts a pending connection request.
public TcpClient AcceptTcpClient()
Returns
- TcpClient
A TcpClient used to send and receive data.
Start(int)
Starts listening for incoming connection requests with a maximum number of pending connection.
public void Start(int backlog)
Parameters
backlog
intThe maximum length of the pending connections queue.
Stop()
Closes the listener.
public void Stop()