Properties of FB_TCPClient/FB_TCPClient2

General Information

The function blocks FB_TCPClient and FB_TCPClient2 provide several properties for their monitoring and control. The properties and their membership are listed in the following tables.

Common Properties of FB_TCPClient and FB_TCPClient2

Name

Data type

Access

Description

IsReadable

BOOL

Read

Indicates that data has been received that has not yet been processed by the Receive method.

IsWritable

BOOL

Read

Indicates that the connection is in a state where data can be sent to the server.

PeerHasDisconnected

BOOL

Read

Indicates that the connection has been closed by the remote site. If so, the method Shutdown is automatically called and the state changes to Shutdown.

Result

ET_Result

Read

Indicates the result of the last method call.

If the result is different than Ok, the result value is maintained even if another method is called.

State

ET_State

Read

Indicates the state of the socket.

TotalBytesReceived

ULINT

Read

Counts the total number of bytes received. (Range: 1 ... 264-1)

TotalBytesSent

ULINT

Read

Counts the total number of bytes sent. (Range: 1 ... 264-1)

SockOpt_CustomPort

UDINT

Read/write

Is used to specify the TCP port to which the connection opened by the FB_TcpClient is to be bound. If the value is set to 0 (default), the next available port is used.

SockOpt_KeepAlive

BOOL

Read/write

If TRUE, instructs the TCP stack to send empty packets periodically to verify whether the remote site is reachable. If this is no longer the case, the connection state changes to Shutdown.

NOTE: In most cases, set this option so that if the remote site is unreachable (powered off or cable disconnected), this is detected.
NOTE: If the KeepAlive socket option is disabled for the server, it cannot be enabled for the connected clients.

SockOpt_NoDelay

BOOL

Read/write

If TRUE, instructs the TCP stack to send the data without waiting for a complete packet. This option reduces throughput but improves latency.

SockOpt_ReceiveBufferSize

UDINT

Read/write

Is used to set or get the receive buffer size of the stack. It must be greater than the amount of data received at one time to help avoid data loss. (Range: 1 ... 2147483647)

SockOpt_SendBufferSize

UDINT

Read/write

Is used to set or get the send buffer size of the stack. It must be greater than the amount of data sent at one time.

(Range: 1 ... 2147483647)

Additional Properties of FB_TCPClient

Name

Data type

Access

Description

BytesAvailableToRead

UDINT

Read

Indicates the number of bytes in the receive buffer available to be read using the Receive method. (Range: 0 ... 2147483647)

SockOpt_OutOfBandInline

BOOL

Read/write

If TRUE, instructs the TCP stack to send OutOfBand-data as part of the regular data stream.

Additional Properties of FB_TCPClient2

Name

Data type

Access

Description

TimeoutConnectTls

UDINT

Read/write

Indicates the timeout in seconds for establishing a connection using the method ConnectTls.

TlsUsed

BOOL

Read

Indicates if the TCP connection to the server has been established using the method ConnectTls.