TCP_Client (FB)¶
FUNCTION_BLOCK TCP_Client EXTENDS CBM.LTrig
Implements a TCP Client.
To connect to a TCP Server at the endpoint defined with ipAddr and uiPort
the input xEnable should set to TRUE.
While setup the connection xBusy is TRUE but xActive is FALSE.
After the connection is established xActive and xBusy is TRUE
and the hConnection output is valid.
After closing the connection from the server side
xActive becomes FALSE hConnection become CAA.gc_hINVALID and
xDone becomes TRUE.
- InOut:
Scope
Name
Type
Initial
Comment
Inherited from
Input
xEnableBOOLTRUE: Action startsFALSE: Action stops, outputsxDone,xBusy,xErrorare resettedLTrig
Output
xDoneBOOLTRUE: Action successfully completedLTrig
xBusyBOOLTRUE: Function block activeLTrig
xErrorBOOLTRUE: Error occurred, function block aborts actionFALSE: No errorLTrig
Input
udiTimeOutUDINT0
Defines the time (µs) after which the connection setup aborts with an error message.
ipAddrIP-Address of server to connect to
uiPortUINTPort number of TCP socket to open
Output
eErrorxActiveBOOLTRUE if a Connection is established
hConnectionCAA.HANDLEValid, if xActive = TRUE