udpStopListen  (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

1.00 / 1.00.00


This stops to listen for data on the specified connection ID.

 

 

Input:                

id : SINT

ID for the connection.

 

Returns: INT

0 if successful, -1 indicates that the passed ID is illegal.

 

Declaration:

FUNCTION udpStopListen : INT;
VAR_INPUT
  id : SINT; // ID of the connection.
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
  server_active : BOOL; | listen for incoming when active
END_VAR;
 
PROGRAM udp_server;
VAR
  port   : INT := 2500; // port to receive data on
  udp_id : SINT;         // listener ID
  rip   : DINT := 0;   // remote IP to receive data from 0=ALL
  status : RF_TRIG ;     // Declare an instance of the RF_TRIG
END_VAR;
 
gsmPower(power := ON);
gprsOpen();
 
BEGIN
  // start / stop based on input
  status(trig := server_active);
  // detect start/stop/running
  IF status.rq THEN
     // Listen for incoming connection on a UDP port
     udp_id := udpStartListen(port := port, rip := rip);
  ELSIF status.fq THEN
    // Terminate listening on a UDP port
    udpStopListen(id := udp_id);
  END_IF;
END;
END_PROGRAM;