HalNineThousand has asked for the wisdom of the Perl Monks concerning the following question:
I read a similar thread that provided an answer that didn't work. I need to find a computer on a LAN. I'll have minimal information, but I can make sure it listens and responds on a socket, so I want to write a program that sends out a broadcast signal on the LAN. The other computer would receive that signal (which would include the IP address) and be able to send a message back saying, "I'm here!"
I can handle the rest, but I don't know how to open a socket and send a broadcast message to the LAN. (I know how to get the subnet and all else, just can't send the broadcast!)
I did find this in another thread:
use IO::Socket; $sock = new IO::Socket::INET ( PeerAddr => '1.1.1.1', PeerPort => '7070', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sock; print $sock "Hello there!\n"; close($sock);
I did change the IP address to my broadcast address, but could never open that socket. I also tried adding the setting "Type=>SOCK_STREAM" but that didn't help.
How can I use Perl to send a broadcast message to a LAN?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How Do I Do an IP Broadcast in Perl?
by bingos (Vicar) on Sep 26, 2010 at 18:52 UTC | |
by HalNineThousand (Beadle) on Sep 26, 2010 at 19:21 UTC | |
by ikegami (Patriarch) on Sep 26, 2010 at 21:19 UTC | |
by HalNineThousand (Beadle) on Sep 26, 2010 at 19:34 UTC | |
|
Re: How Do I Do an IP Broadcast in Perl?
by oko1 (Deacon) on Sep 27, 2010 at 00:10 UTC | |
|
Re: How Do I Do an IP Broadcast in Perl?
by Khen1950fx (Canon) on Sep 27, 2010 at 11:15 UTC | |
|
Re: How Do I Do an IP Broadcast in Perl?
by zentara (Cardinal) on Sep 27, 2010 at 11:40 UTC | |
by tirwhan (Abbot) on Sep 27, 2010 at 12:33 UTC | |
by zentara (Cardinal) on Sep 27, 2010 at 12:38 UTC | |
by tirwhan (Abbot) on Sep 27, 2010 at 12:42 UTC |