Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: udp broadcast: doesn't work in Linux

by fjonckers (Novice)
on Oct 12, 2001 at 01:27 UTC ( [id://118352]=note: print w/replies, xml ) Need Help??


in reply to udp broadcast: doesn't work in Linux

ok guys, found it...
The option SO_BROADCAST requests permission to send broadcast datagrams on the socket. Broadcast was a privileged operation in earlier versions of the system.
so, I rewrote my snippet:
#!/usr/bin/perl # use strict; use IO::Socket; # defaults my $bcaddr = '192.168.254.255'; my $port = 9870; socket(sock, PF_INET, SOCK_DGRAM, getprotobyname("udp")) or die "socket:$@"; setsockopt(sock, SOL_SOCKET, SO_BROADCAST, 1) or die "setsockopt:$@"; my $dest = sockaddr_in($port,inet_aton($bcaddr)); # 10 udp's on the wire for (my $i=0;$i < 10;$i++) { my $data = 'UDP packet ' . $i; # send udp packet send(sock,$data,0,$dest) || die "send(): $!"; }
doesn't seem to work with IO::Socket::INET->new
thanks for the tips! made me look further than Perl (C, kernel)...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://118352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-23 22:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found