Skip to main content

TcpListener Class

NuGet: GHIElectronics.TinyCLR.Networking
Assembly: GHIElectronics.TinyCLR.Networking
Namespace: System.Net.Sockets

Listens for connections from TCP network clients.

public class TcpListener

Constructors​

TcpListener(IPEndPoint localEP)​

public TcpListener(IPEndPoint localEP)

Initializes a new instance that listens on the specified local endpoint.

TcpListener(IPAddress localaddr, int port)​

public TcpListener(IPAddress localaddr, int port) : this(new IPEndPoint(localaddr, port))

Initializes a new instance that listens on the specified local address and port.

Properties​

Server​

public Socket Server { get; }

The underlying socket used by the listener.

Active​

protected bool Active { get; }

Whether the listener is actively listening for connections.

LocalEndpoint​

public EndPoint LocalEndpoint { get; }

The local endpoint the listener is bound to.

Methods​

Start()​

public void Start()

Starts listening for incoming connection requests.

Start(int backlog)​

public void Start(int backlog)

Starts listening with the specified maximum length of the pending connection queue.

Stop()​

public void Stop()

Stops listening for incoming connection requests.

Pending()​

public bool Pending()

Determines whether a connection request is pending.

Returns bool

AcceptSocket()​

public Socket AcceptSocket()

Accepts a pending connection request and returns a Socket.

Returns Socket

AcceptTcpClient()​

public TcpClient AcceptTcpClient()

Accepts a pending connection request and returns a TcpClient.

Returns TcpClient

Create(int port)​

public static TcpListener Create(int port)

Creates a listener that listens on any local interface using the specified port.

Returns TcpListener