Anyone hackers here sent broadcast packets? I think this is how you
do it:

#!/usr/bin/perl -w
use strict;

use Socket;
my $dst = inet_aton("172.30.255.255");

socket(SOCKET, PF_INET, SOCK_DGRAM, getprotobyname("udp"))
        or die "socket: $!";
setsockopt(SOCKET, SOL_SOCKET, SO_BROADCAST, pack("l", 1))
        or die "setsockopt: $!";
send(SOCKET, "hello", 0, sockaddr_in(6868, INADDR_BROADCAST))  
#send(SOCKET, "hello", 0, sockaddr_in(6868, $dst))
        or die "send: $!";

For some reason I'm getting "send: Can't assign requested address"
for INADDR_BROADCAST. How can it *not* assign that? Flipping the
comments over works fine (for that subnet) -- in other words, in my
C code, I have to spelunk the interface list with ioctl()s and then
get the sodding broadcast address. Which is a lot of work :-(

FWIW (this is on the failing machine, yes different subnet),

en0: flags=8963<UP,BROADCAST,b6,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
        inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
        ether 00:30:65:7e:d1:96 
        media: autoselect (none) status: inactive
        supported media: none autoselect 10baseT/UTP <half-duplex> 10baseT/UTP 
<full-duplex> 100baseTX <half-duplex> 100baseTX <full-duplex>

Any ideas?

Paul

Reply via email to