Re: Receive UDP Broadcast

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


hey, thx for reply! the problem was myself, my firewall was blocking the incoming traffic for *facepalm* i have also find a solution for interface binding, by the undocumented constant like this:

$address = 'udp://';
$stream = stream_socket_server($address, $errno, $errstr, \STREAM_SERVER_BIND);
$socket = socket_import_stream($stream);
socket_set_option($socket, SOL_SOCKET, SO_BINDTODEVICE, 'eth2');


On 06.03.22 21:02, Andrey Repin wrote:
Greetings, worker@xxxxxxx.
In reply to Your message dated Friday, February 25, 2022, 16:13:39,


how can i receive an UDP broadcast to on an dedicated interface?

this is my first try, but no luck, how can i enable the broadcast feature for my socket?

             $address = 'udp://';
#            $address = 'udp://'; // not working
#            $address = 'udp://'; //also not working, so i missing the interface binding to?!
For the starter, have you tried for testing purposes?

             $context = stream_context_create([
                 'socket' => [
                     'so_broadcast' => 1,
             $socket = @\stream_socket_server($address, $errno, $errstr, \STREAM_SERVER_BIND, $context);
And remove @. If you want error handling - implement error handling. But don't mute errors.

my code is working fine for any unicast packet, but broadcast isnt reache this socket. the excepted broadcast-packets can i see with tcpdump on my          server-intrerface.

any hints for my problem?

regards, volker.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux