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