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
xEnable
BOOL
TRUE
: Action startsFALSE
: Action stops, outputsxDone
,xBusy
,xError
are resettedLTrig
Output
xDone
BOOL
TRUE
: Action successfully completedLTrig
xBusy
BOOL
TRUE
: Function block activeLTrig
xError
BOOL
TRUE
: Error occurred, function block aborts actionFALSE
: No errorLTrig
Input
udiTimeOut
UDINT
0
Defines the time (µs) after which the connection setup aborts with an error message.
ipAddr
IP-Address of server to connect to
uiPort
UINT
Port number of TCP socket to open
Output
eError
xActive
BOOL
TRUE if a Connection is established
hConnection
CAA.HANDLE
Valid, if xActive = TRUE