Skip to main content

TcpClient Class

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

Provides client connections for TCP network services.

public class TcpClient : IDisposable

Constructors

TcpClient()

public TcpClient() : this(AddressFamily.Unknown)

Initializes a new instance with the default address family.

TcpClient(AddressFamily family)

public TcpClient(AddressFamily family)

Initializes a new instance using the specified address family.

TcpClient(IPEndPoint localEP)

public TcpClient(IPEndPoint localEP)

Initializes a new instance and binds it to the specified local endpoint.

TcpClient(string hostname, int port)

public TcpClient(string hostname, int port) : this(AddressFamily.Unknown)

Initializes a new instance and connects to the specified host and port.

Properties

Active

protected bool Active { get; set; }

Whether a connection has been established.

Available

public int Available { get; }

The number of bytes available to be read from the connection.

Client

public Socket Client { get; set; }

The underlying socket used by the client.

Connected

public bool Connected { get; }

Whether the client is connected to a remote host.

ReceiveBufferSize

public int ReceiveBufferSize { get; set; }

The size, in bytes, of the receive buffer.

SendBufferSize

public int SendBufferSize { get; set; }

The size, in bytes, of the send buffer.

ReceiveTimeout

public int ReceiveTimeout { get; set; }

The amount of time, in milliseconds, that a receive operation waits before timing out.

SendTimeout

public int SendTimeout { get; set; }

The amount of time, in milliseconds, that a send operation waits before timing out.

Methods

Connect(string hostname, int port)

public void Connect(string hostname, int port)

Connects the client to the specified host and port.

Connect(IPAddress address, int port)

public void Connect(IPAddress address, int port)

Connects the client to the specified IP address and port.

Connect(IPEndPoint remoteEP)

public void Connect(IPEndPoint remoteEP)

Connects the client to the specified remote endpoint.

Connect(IPAddress[] ipAddresses, int port)

public void Connect(IPAddress[] ipAddresses, int port)

Connects the client to the first of the specified IP addresses on the given port.

GetStream()

public NetworkStream GetStream()

Returns the network stream used to send and receive data.

Returns NetworkStream

Close()

public void Close()

Closes the client and releases its resources.

Dispose(bool disposing)

protected virtual void Dispose(bool disposing)

Releases the resources used by the client.

Dispose()

public void Dispose()

Releases the resources used by the client.