FB_IpStartSession
The function block allocates resources on the controller for the Ethernet communication. The function block becomes active with bStart. bBusy is set as long as the function block is busy. iDevice should always be zero. iPort is used for the local TCP or UDP port number. iMaxConnection indicates the maximum number of possible connections (up to 3).

INPUT
VAR_INPUT
bStart : BOOL;
iDevice : WORD;
eSocketType : E_SocketType;
eSocketProtocol : E_SocketProtocol;
iPort : WORD;
iMayConnection : WORD;
tTimeout : TIME;
END_VAR
bStart: A rising edge activates the function block.
iDevice: always "0"
eSocketType: For TCP/IP "SOCK_STREAM" should be used. Please note that the data are stored as a byte stream. If possible, the length of the received data should be known or a protocol with start and end ID should be used, so that the start and end can be detect unambiguously in the data stream. For UDP/IP "SOCK_DGRAM" should be set. A UDP frame always stored in the memory as a complete entity. 4 memories are available. If the data are not read fast enough from the memory of the PLC by the user program further UDP frames are lost.
eSocketProtocol: For TCP/IP "IPPROTO_TCP" should be used, for UDP/IP "IPPROTO_UDP".
iPort: Sender port number
iMaxConnection: Number of possible connections (max. 3)
tTimeout: Time after which the attempt is aborted.
OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
iErrorId : WORD;
iSession : WORD;
END_VAR
bBusy: This output remains TRUE until execution of the command is complete.
bError: This output is switched to TRUE as soon as an error occurs during the execution of a command. The command-specific error code is contained in iErrorId.
iErrorId: Contains the command-specific error code of the last executed command (see table).
iSession: Forwards the session number to all IP function blocks for which this connection was created.