I need to get information from UDP socket, but the fact that i do not know how many answers will receive so i decided to wait for a few seconds. The main problem is that socket_recvfrom
blocks and all the code stuck... Is there some way to wait for a few second and stop the socket?
My code:
$end_time = time() + 2;
while ($end_time > time()) {
socket_recvfrom($socket, $buffer, 2500, 0, $from, $port);
var_dump($buffer);
}