Litre
Litre

Reputation: 53

UDP Broadcasting with PHP

I cannot figure how to broadcast a UDP datagram to my local network with PHP. This is the sample code I use :

$socket = stream_socket_client("udp://255.255.255.255:12478", $errno, $errstr);

I tried with 192.168.0.255 instead of 255.255.255.255 but I get the same result :

Warning: stream_socket_client(): unable to connect to udp://255.255.255.255:12478 (Permission denied)

Is this a limitation in the configuration of my OS (Debian Linux) ? Or a misuse of broadcasting options on my side ?

Any help is appreciated ! Thanks !

Lionel

Upvotes: 0

Views: 3593

Answers (1)

symcbean
symcbean

Reputation: 48357

The terms 'udp' and 'stream' are mutually exclusive. Also broadcasting is very different from other network operations.

See the note at the bottom of the socket_sendto() manual page. (The first hit if you google for 'php udp broadcast')

Upvotes: 2

Related Questions