OptoMMP2
ip4.Tcp_Client Class Reference

An class to simplify a TCP/IP client-side socket. More...

Public Member Functions

 Tcp_Client ()
 Constructor for the Tcp_Client. More...
 
void Open (Socket ClientSocket, EndPoint RemoteEndpoint)
 Open a TCP/IP client object from a Socket accepted from the TCP/IP Server Object More...
 
int Open6 (string sHost, int iPort)
 Connect to a TCP/IPv6 Server. (Blocked Call, may take up to 30 seconds to complete) More...
 
int Open (string sHost, int iPort)
 Connect to a TCP/IPv4 Server. (Blocked Call, may take up to 30 seconds to complete) More...
 
int Open (string sHost, int iPort, int iTimeoutMs)
 Connect to a TCP/IPv4 Server. (Blocked version with timeout) More...
 
int Open6 (string sHost, int iPort, int iTimeoutMs)
 Connect to a TCP/IPv6 Server. (Blocked version with timeout) More...
 
bool IsOpen ()
 Tests to see if the socket is writeable. More...
 
int Close ()
 Close the TCP/IP connection. More...
 
int Receive (byte[] byary, int i32Timeout_Ms)
 Receive data from the TCP/IP connection. More...
 
int Receive (byte[] byary, int iOffset, int iMaxSize, int i32Timeout_Ms)
 Receive data from the TCP/IP connection and store to a particular section of the byte array. More...
 
int Send (byte[] byary, int i32Tx_Length)
 Send data to TCP/IP remote host. More...
 

Public Attributes

string strError = ""
 Last Exception Thrown (when -1 is returned). More...
 

Detailed Description

An class to simplify a TCP/IP client-side socket.

Constructor & Destructor Documentation

ip4.Tcp_Client.Tcp_Client ( )

Constructor for the Tcp_Client.

Member Function Documentation

int ip4.Tcp_Client.Close ( )

Close the TCP/IP connection.

Returns
-1 if a fault occured. The object is still closed if -1 returns. Check strLastFault for message.
bool ip4.Tcp_Client.IsOpen ( )

Tests to see if the socket is writeable.

Valid half-open TCP sockets will appear writeable. This function only tests to see if the socket appears if data may be sent and after the "connect" has been validated and completed.

Returns
True if the socket is open and appears writeable. False otherwise.
void ip4.Tcp_Client.Open ( Socket  ClientSocket,
EndPoint  RemoteEndpoint 
)

Open a TCP/IP client object from a Socket accepted from the TCP/IP Server Object

Parameters
ClientSocketThe accepted TCP/IP socket returned from Tcp_Server.Accept()
RemoteEndpointAn endpoint structure from the Accept method.
int ip4.Tcp_Client.Open ( string  sHost,
int  iPort 
)

Connect to a TCP/IPv4 Server. (Blocked Call, may take up to 30 seconds to complete)

Parameters
sHostHost name in name or dot IP Address format.
iPortTCP/IP server port to connect too.
Returns
0 indicates success, -1 indicates failure
int ip4.Tcp_Client.Open ( string  sHost,
int  iPort,
int  iTimeoutMs 
)

Connect to a TCP/IPv4 Server. (Blocked version with timeout)

Parameters
sHostHost name in name or dot IP Address format.
iPortTCP/IP server port to connect too.
iTimeoutMsTimeout is Milliseconds to wait for the connection to complete.
Returns
0 indicates success, -1 indicates failure
int ip4.Tcp_Client.Open6 ( string  sHost,
int  iPort 
)

Connect to a TCP/IPv6 Server. (Blocked Call, may take up to 30 seconds to complete)

Parameters
sHostIPV6 Host name in name or colon address format.
iPortTCP/IP server port to connect too.
Returns
0 indicates success, -1 indicates failure
int ip4.Tcp_Client.Open6 ( string  sHost,
int  iPort,
int  iTimeoutMs 
)

Connect to a TCP/IPv6 Server. (Blocked version with timeout)

Parameters
sHostHost name in name or dot IP Address format.
iPortTCP/IP server port to connect too.
iTimeoutMsTimeout is Milliseconds to wait for the connection to complete.
Returns
0 indicates success, -1 indicates failure
int ip4.Tcp_Client.Receive ( byte[]  byary,
int  i32Timeout_Ms 
)

Receive data from the TCP/IP connection.

Parameters
byaryByte array to store the received data.
i32Timeout_MsTimeout interval in milliseconds.
Returns
Positive values for data received, zero for timeout. When receiving a negative value, close the socket.
int ip4.Tcp_Client.Receive ( byte[]  byary,
int  iOffset,
int  iMaxSize,
int  i32Timeout_Ms 
)

Receive data from the TCP/IP connection and store to a particular section of the byte array.

Parameters
byaryByte array to store the received data.
iOffsetOffset in the buffer to begin receiving data.
iMaxSizeThe maximum receive size to byary. Allows receives smaller than byary.
i32Timeout_MsTimeout interval in milliseconds.
Returns
Positive values for data received, zero for timeout. When receiving a negative value, close the socket.
int ip4.Tcp_Client.Send ( byte[]  byary,
int  i32Tx_Length 
)

Send data to TCP/IP remote host.

Parameters
byaryBytes to send. Should at least be i32Tx_Length.
i32Tx_LengthNumber of bytes to send.
Returns
0 indicates success, if -1 returned, close the TCP/IP connection.

Member Data Documentation

string ip4.Tcp_Client.strError = ""

Last Exception Thrown (when -1 is returned).


The documentation for this class was generated from the following file: