OptoMMP3
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
Opto22.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...
 
Int32 Open (String sHost, Int32 i32Port, Int32 i32TimeoutMs)
 Connect to a TCP/IPv4 Server. (Blocked version with timeout) More...
 
Int32 Open6 (String sHost, Int32 i32Port, Int32 i32TimeoutMs)
 Connect to a TCP/IPv6 Server. (Blocked version with timeout) More...
 
Boolean IsOpen ()
 Tests to see if the socket is writeable. Does not mean the network is available to transmit. More...
 
Int32 Close ()
 Close the TCP/IP connection. More...
 
Int32 Receive (Byte[] byary, Int32 i32Timeout_Ms)
 Receive data from the TCP/IP connection. More...
 
Int32 Receive (Byte[] byary, Int32 i32Offset, Int32 i32MaxSize, Int32 i32TimeoutMs)
 Receive data from the TCP/IP connection and store to a particular section of the byte array. More...
 
Int32 Send (Byte[] byary, Int32 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.

Exposed to help users of SNAP-PAC Serial Modules. Property Socket.NoDelay is set to true to provide as responsive data transmission as possible.

Constructor & Destructor Documentation

Opto22.Ip4.Tcp_Client.Tcp_Client ( )

Constructor for the Tcp_Client.

Member Function Documentation

Int32 Opto22.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.
Boolean Opto22.Ip4.Tcp_Client.IsOpen ( )

Tests to see if the socket is writeable. Does not mean the network is available to transmit.

Please see the internet for additional information for half-open TCP sessions.

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.
Int32 Opto22.Ip4.Tcp_Client.Open ( String  sHost,
Int32  i32Port,
Int32  i32TimeoutMs 
)

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

Parameters
sHostHost name in name or dot IP Address format.
i32PortTCP/IP server port to connect too.
i32TimeoutMsTimeout is Milliseconds to wait for the connection to complete.
Returns
0 indicates success, -1 indicates failure
Int32 Opto22.Ip4.Tcp_Client.Open6 ( String  sHost,
Int32  i32Port,
Int32  i32TimeoutMs 
)

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

Parameters
sHostHost name in name or dot IP Address format.
i32PortTCP/IP server port to connect too.
i32TimeoutMsTimeout is Milliseconds to wait for the connection to complete.
Returns
0 indicates success, -1 indicates failure
Int32 Opto22.Ip4.Tcp_Client.Receive ( Byte[]  byary,
Int32  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.
Int32 Opto22.Ip4.Tcp_Client.Receive ( Byte[]  byary,
Int32  i32Offset,
Int32  i32MaxSize,
Int32  i32TimeoutMs 
)

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.
i32OffsetOffset in the buffer to begin receiving data.
i32MaxSizeThe maximum receive size to byary. Allows receives smaller than byary.
i32TimeoutMsTimeout interval in milliseconds.
Returns
Positive values for data received, zero for timeout. When receiving a negative value, close the socket.
Int32 Opto22.Ip4.Tcp_Client.Send ( Byte[]  byary,
Int32  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 Opto22.Ip4.Tcp_Client.strError = ""

Last Exception Thrown (when -1 is returned).


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