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!
In reply to How Do I Do an IP Broadcast in Perl? by HalNineThousand
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |