Properties of FB_TCPServer/FB_TCPServer2

General Information

The properties provided by the FB_TCPServer2 have nearly the same function as the corresponding properties provided by the function block FB_TCPServer. The differences are described in the respective table blow.

Common Properties of FB_TCPServer and FB_TCPServer2

Name

Data type

Access

Description

IsDataAvailable

BOOL

Read

Indicates if there is data available to be read from at least 1 client.

IsNewConnectionAvailable

BOOL

Read

Indicates that there is a new incoming connection waiting to be accepted.

NumberOfConnectedClients

UINT

Read

Returns the number of connected clients (including clients that are disconnected but have data to be read). (Range: 0 to GPL.Gc_uiTCPServerMaxConnections)

Result

ET_Result

Read

Indicates the result of the last method call.

If the result is different than Ok, the value is not overwritten not even a 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 to 264-1)

SockOpt_CustomPort

UDINT

Read/write

Is used to enable/disable the SO_LINGER socket option for the connection opened by the FB_TcpServer.

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 disconnected (powered off or cable unplugged) this is detected.

NOTE: If the KeepAlive socket option is disabled for the server, it cannot be enabled for the connected clients.

SockOpt_ReuseAddress

BOOL

Read/write

If TRUE, it allows to open a server even if the port is still bound to, but not actively used by another resource.

SockOpt_ReceiveBufferSize

UDINT

Read/write

Is used to set or get the receive buffer size of the stack. It should always 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 should always be greater than the amount of data sent at 1 time.

(Range: 1 ... 2147483647)

Additional Properties of FB_TCPServer

Name

Data type

Access

Description

BytesAvailableToReadFirstAvailableClient

UDINT

Read

Indicates the number of bytes available to be read from the first client that has data available. (Range: 0 ... 2147483647)

BytesAvailableToReadTotal

UDINT

Read

Indicates the total number (sum) of bytes available to be read from the connected clients. (Range: 0 ... 2147483647)

ConnectedClients

ARRAY [1..GPL. Gc_uiTCPServerMaxConnections] OF ST_ClientConnection

Read

Returns an array with information about the connected clients. Refer to ST_ClientConnection.

Additional Properties of FB_TCPServer2

Name

Data type

Access

Description

ConnectedClients2

ARRAY [1..GPL. Gc_uiTCPServerMaxConnections] OF ST_ClientConnection2

Read

Returns an array with information about the connected clients. Refer to ST_ClientConnection2.

TimeoutAcceptTls

UDINT

Read/write

Indicates the timeout in seconds for accepting an incoming connection using the method Accept on ports opened with method OpenTls.

TlsUsed

BOOL

Read

Indicates if tport has been opened using the method OpenTls.