FCT_CONNECT: Establishes a Connection with an IP Address
(Original Document)
Function Description
The FCT_CONNECT function is used to establish a connection to a known port and internet address.
The additional parameters EN and ENO may be configured.
Representation in FBD
Representation in LD
Representation in IL
LD Module_Number
FCT_CONNECT Socket_Number, Serv_Index, Gest_Index, Server_Address, Management_Param
Representation in ST
FCT_CONNECT(Module_Number, Socket_Number, Serv_Index, Gest_Index, Server_Address, Management_Param);
Description of Parameters
The following table describes the input parameters:
Parameter
Type
Comment
Module_Number
Slot number of network module in rack 0.
  • Low byte is the slot number of network module in rack 0.
  • High byte can be used to extend the number of sockets.
    • 00: Provided for full backward compatibility with applications created on firmware version 3.3 or earlier.
    • 01: Up to 64 sockets can be used (firmware version must be higher than 3.3).
Socket_Number
Socket number
Serv_Index
Index of first word in Server_Address array
Gest_Index
Index of first word in Management_Param array
Server_Address
Array of 3 words containing the port number and IP address of the server
The following table describes the input/output parameters:
Parameter
Type
Comment
Management_Param
ARRAY [0... 3] OF INT
The operation report can have the following values:
  • 16#00: Correct operation.
  • 16#09: Invalid socket number.
  • 16#16: Invalid parameter.
  • 16#20: Connection is cut.
  • 16#24: Connection in progress.
  • 16#38: Socket already connected.
  • 16#3D: Connection refused.
  • 16#41: No route to host.
Configuring Port Numbers Above 32K
The data type of the port parameter is an integer. In order to use port numbers higher than 15 bits (higher than 32K), you must use the UINT_TO_INT function block to convert the Unsigned Integer format (encoded in 16 bits) to an Integer format. Use the UINT_TO_INT function block before using EF FCT_BIND or FCT_CONNECT when a port number higher than 32K is used.
Input parameter:
Parameter
Data Type
Meaning
UINT_variable
UINT
input value
Output parameter:
Parameter
Data Type
Meaning
ConvertedVariable
INT
output value