I have a php application that manipulates database and supplying REST API for clients, it works fine.
I was asked to add it capabilities to listen to UDP port, 24/7, and use whatever is submitted through that socket, and add it to the database.
I know how to create a socket with php, and get the data from it. but it's a php page that i need to execute, and the time limit of the script is N seconds.
What is the proper way to run that script as a "listening server" that will execute the relevant code?
I use apache/php on windows.
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_bind($socket, '127.0.0.1', 1223); $from = ''; $port = 0; socket_recvfrom($socket, $buf, 12, 0, $from, $port); echo "Received $buf from remote address $from and remote port $port" . PHP_EOL; ?>