0

I am developing a web application in PHP which will receive messages through the UDP protocol. The devices on the other side are broadcasting messages for specific port and I just want to listen on this port and save all those messages. I was trying to do this without success. There was always have to specify the IP from where you can receive messages. Is this possible in PHP? I already did it in Java, so I assume it is practically possible, but not sure for PHP technology.

Thanks for the answers in advance.

  • I think it's possible to open a port in php to listen for udp signals. Somebody gave an example in this question: http://stackoverflow.com/questions/20635242/receive-udp-packet-datagrams-in-php But if you already have a firewall blocking this port or if php can't open the port because it doesn't have the privilege to do so, then php won't get the message. – Kerridge0 Aug 05 '15 at 21:37

1 Answers1

0

Can you test with address 0.0.0.0: "socket_bind($sock, "0.0.0.0" , $portNumber)".

Peter Peng
  • 1,910
  • 1
  • 27
  • 37
  • socket_bind ($socket, 0, $portNumber) or socket_bind($sock, "0.0.0.0" , $portNumber) allows to accept from any IP. Can it be caused by the port number used? – Peter Peng Aug 05 '15 at 21:52