FB_IpOpen

The function block is required for opening a TCP/IP connection from the PLC controller. In this case is the controller is the client that actively establishes a connection to a TCP/IP server. With a positive edge of bStart a connection to a server with the IP address from sRemoteIpAddr is established. The recipient port number was specified when the session was started (see FB_IpStartSession). The sender port number is issued by the controller and can be read from iPortNo. The sender port number is required for sending (see FB_IpSend). bBusy is set as long set as the function block is active. If bBusy is reset and bError is FALSE the TCP/IP connection was terminated successfully and data can be sent or received.

FB_IpOpen 1:
Function block FB_IPOPEN

INPUT

VAR_INPUT
   bStart         : BOOL;
   iSession       : WORD;
   sRemoteIPAddr  : STRING(15);   
END_VAR

bStart: A rising edge activates the function block.

iSession: Is linked with the session number from function block FB_IpStartSession.

OUTPUT

VAR_OUTPUT
   bBusy        : BOOL;
   bError       : BOOL;
   iErrorId     : WORD;
   iPortNo      : 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 most recently executed command (see table).

iPortNo: TCP port number that was allocated when the TCP/IP connection was opened (local port number).