title: PHP : Send an UDP broadcast message , and wait the response
body: <p>I used this code to send an UDP broadcast message</p>
  
  <pre><code>$ip = "255.255.255.255";
  $port = 8888;
  $str = "DEVICE_DISCOVERY";
  
  $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 
  socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1); 
  socket_sendto($sock, $str, strlen($str), 0, $ip, $port);
  
  socket_recvfrom($sock, $buf, 20, 0, $ip, $port);
  echo "Messagge : &lt; $buf &gt; , $ip : $port &lt;br&gt;";
  
  socket_close($sock);
  </code></pre>
  
  <p>I want that some specific network devices (in my case is some <strong>Arduino</strong> boards with ethernet shield) respond with a particular message. </p>
  
  <p>The code works, but in this way i can't print all the responses but only one.</p>