FCT_BIND: Binds a Socket Number to an IP Address and a Port
(Original Document)
Function Description
The FCT_BIND function is used to assign a port number and an internet address to a socket.
A socket is created without an address and cannot be used to receive data (except for connection requests) until it is assigned one. The internet address is fixed by the network module to its local configured IP address. The user is not allowed to use some port numbers because they are already used by the network module. These port numbers are:
The additional parameters EN and ENO may be configured.
Representation in FBD
Representation in LD
Representation in IL
LD Module_Number
FCT_BIND Socket_Number, Port_Number, Gest_Index, Management_Param
Representation in ST
FCT_BIND(Module_Number, Socket_Number, Port_Number, Gest_Index, 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
Port_Number
Port number to be assigned to socket
Gest_Index
Index of first word in Management_Param array
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: No error.
  • 16#09: The socket number is invalid.
  • 16#16: The socket is already bound.
  • 16#30: The specified port is already in use.
  • 16#37: The specified port number is not available.
  • 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