The global variable list contains the global variables of the TcpUdpCommunication library.
The global variables are automatically used by the respective function blocks.
Variable |
Data type |
Description |
---|---|---|
G_stDefaultSocketOptionsTCPClient |
ST_DefaultSocketOptionsTCPClient |
Default value for socket options that are set when a TCP client connection is initialized. |
G_stDefaultSocketOptionsTCPServer |
ST_DefaultSocketOptionsTCPServer |
Default value for socket options that are set when a TCP server socket is initialized. |
G_stDefaultSocketOptionsUDPPeer |
ST_DefaultSocketOptionsUDPPeer |
Default value for socket options that are set when a UDP socket is initialized. |
G_xDisableAsyncExecTcpClient |
BOOL |
If TRUE, the asynchronous execution of the program code for establishing a secured connection is disabled.(1) Default value: FALSE |
G_xDisableAsyncExecTcpServer |
BOOL |
If TRUE, the asynchronous execution of the program code for opening a secure socket and for accepting an incoming connection is disabled.(1) Default value: FALSE |
(1) Disabling the asynchronous execution means that the program code is executed synchronous in the calling task. This leads to a significantly increased execution time for at least one task cycle during the process. |
The code example shows how to change the default socket option for the TCP client implementation. In this example, the default receive buffer size is set to 10000 Bytes. This default value is applied for each new connection as long as the variable xModifyReceiveBufferSize is TRUE.
IF NOT xInitDone THEN
// Enable the use of user defined default socket options
TCPUDP.GVL.G_stDefaultSocketOptionsTCPClient.xModifyReceiveBufferSize := TRUE;
// Set the values for the default socket options
TCPUDP.GVL.G_stDefaultSocketOptionsTCPClient.udiReceiveBufferSizeValue := 10000;
xInitDone := TRUE;
END_IF
// Connect to the server
IF (fbTcpClient.State = TCPUDP.ET_State.Idle) AND xConnect THEN
xConnectDone := fbTcpClient.Connect(i_sServerIP:= '192.168.100.11', i_uiServerPort:= 12345);
IF NOT xConnectDone THEN
; // error handling
END_IF
xConnect :=FALSE;
END_IF