PHP/UDP: Can write via UDP, but recieving data seams not possible

Problem solved by using this code. Apparently one has to close the socket after sending and open a new one for receiving. It seams to be a unique behaviour of this device (server):

$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$bytes = socket_sendto($socket, $message, strlen($message), 0, "", 7090);

$message="curr 7700";
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, '', 7090);
$from = '';
$port = 0;
socket_recvfrom($socket, $buf, 512, 0, $from, $port);
echo $buf . PHP_EOL;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top