Class TcpClient
Provides client connections for TCP network services.
public class TcpClient : IDisposable
- Inheritance
-
TcpClient
- Implements
- Inherited Members
- Extension Methods
Constructors
TcpClient()
Initializes a new instance of the TcpClient class.
public TcpClient()
TcpClient(IPEndPoint)
Initializes a new instance of the TcpClient class with specified end point
public TcpClient(IPEndPoint localEP)
Parameters
localEP
IPEndPoint
TcpClient(AddressFamily)
Initializes a new instance of the TcpClient class with address family.
public TcpClient(AddressFamily family)
Parameters
family
AddressFamily
TcpClient(string, int)
Initializes a new instance of the TcpClient class, Bind and connect to host name and port.
public TcpClient(string hostname, int port)
Parameters
Properties
Available
Gets the amount of data that has been received from the network and is available to be read.
public int Available { get; }
Property Value
Client
Gets or sets the underlying Socket.
public Socket Client { get; set; }
Property Value
LingerState
Gets or sets the value of the connection's linger option
public LingerOption LingerState { get; set; }
Property Value
NoDelay
Enables or disables delay when send or receive buffers are not full. (Nagle) True if delay is disabled.
public bool NoDelay { get; set; }
Property Value
ReceiveTimeout
Gets or sets the receive time out value of the connection in seconds.
public int ReceiveTimeout { get; set; }
Property Value
SendTimeout
Gets or sets the send time out value of the connection in seconds.
public int SendTimeout { get; set; }
Property Value
Methods
Close()
Disposes this TcpClient instance and requests that the underlying TCP connection be closed.
public void Close()
Connect(IPAddress, int)
Connects the client to a remote TCP host using the specified IP address and port number.
public void Connect(IPAddress address, int port)
Parameters
address
IPAddressThe IPAddress of the host to which you intend to connect.
port
intThe port number to which you intend to connect.
Connect(IPAddress[], int)
Connects the client to a remote TCP host using the specified IP addresses and port number.
public void Connect(IPAddress[] address, int port)
Parameters
address
IPAddress[]The IPAddress array of the host to which you intend to connect.
port
intThe port number to which you intend to connect.
Connect(IPEndPoint)
Connects the client to a remote TCP host using the specified remote network endpoint.
public void Connect(IPEndPoint remoteEP)
Parameters
remoteEP
IPEndPointThe IPEndPoint to which you intend to connect.
Connect(string, int)
Connects the Client to the specified port on the specified host.
public void Connect(string hostname, int port)
Parameters
Dispose()
Dispose TcpClient
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
GetStream()
Returns the NetworkStream used to send and receive data to remote host.
public NetworkStream GetStream()
Returns
- NetworkStream
The underlying NetworkStream.