Skip to main content

7.15.12 Configure UDP local parameters

Note
  • Each UDP_Config represents an Ethernet connection
  • T3 supports up to 8 Ethernet connections (including TCP and UDP), and T4 supports up to 32 Ethernet connections (including TCP and UDP)

Function

  • UDP_Config (function block): Configure UDP local parameters

Parameter description

Interface variablesStatementData typeDescription
MODESTATICUSINTUDP communication mode selection, Default = 0, select UDP unicast mode for communication; MODE = 1, select UDP broadcast mode for communication
LocalAddressSTATICARRAY[0..3] OF BYTEThe local IP address cannot be 0.0.0.0, and the PLC network port corresponding to the IP address must currently be Ethernet protocol, rather than EC protocol or other protocols
LocalPortSTATICUINTLocal Port Number
MULTICASTTTLSTATICUSINT(V1.1 is not currently used, suitable for subsequent multicast modes) The survival time of UDP packets is, default to 1, indicating that the packet will be automatically lost by the kernel after passing through at most one router
  • The UDP_Config function block is only used to configure the corresponding IP address and port number of the user; the meaning of each parameter is as follows:
    • Parameter MODE: This parameter is used by the user to select the current UDP communication mode. Default = 0, select UDP unicast mode for communication; MODE = 1, select UDP broadcast mode for communication. (V1.1 version currently only supports unicast and broadcast modes)
    • Parameters LocalAddress and LocalPort: Denoted as the actual IP address of the current PLC and the port number that needs to be bound; the current LocalAddress cannot be 0.0.0.0, otherwise an error of 0x8081 (ip address error); and the PLC network port corresponding to LocalAddress can only be an Ethernet protocol, not an EC protocol or other protocol, otherwise an error of 0x8081 (ip address error). For LocalPort, in order to avoid collision with other system service port numbers, error 0x8083 is reported (bind address and port number and socket failed), it is recommended that LocalPort use range is 2000-5000
    • Parameter MULTICASTTTL: (V1.1 is not currently used and is suitable for subsequent multicast modes.) The survival time of UDP packets is 1 by default, indicating that the packet will be automatically lost by the kernel after passing through at most one router.