Methods of FB_TCPClient/FB_TCPClient2

Overview

The methods provided by the FB_TCPClient2 have nearly the same function as the corresponding methods provided by the function block FB_TCPClient. The differences are described in the table below.

Method

FB_TCPClient

FB_TCPClient2

Close

x

x

Connect

x

x

ConnectStartTls

-

x

ConnectTls

-

x

GetBoundIPAddress

x

x

GetBoundPort

x

x

Peek

x

x

Receive

x

x

ReceiveOutOfBand

x

-

ResetByteCounters

x

x

ResetResult

x

x

Send

x

x

SendOutOfBand

x

-

Shutdown

x

x

SockOpt_EnableKeepAliveExtended

x

x

UpgradeToTls

-

x

x Supported by the function block.

- Not supported by the function block.

Performance Considerations

When a certain amount of data needs to be available to be processed correctly, two approaches by the application are possible:

  • The Peek method is used to copy the available data to an empty buffer provided by the application. This data can then be used to evaluate if there is enough data in the buffer. If so, the Receive method is used to move the data from the receive buffer of the system to the application and process it there.

  • Only the Receive method is called, but always on the same buffer provided by the application and specifying the fill level of that buffer. This way, the data is only copied once and the application can evaluate whether there is enough data and process it in one call of the method since the data is already in the buffer used by the application.

The second approach avoids copying data in memory multiple times.