new IO::Socket::INET + UDP/Broadcast = Permission denied ?? Why?

S

Snail

The Following code works fine on my Win32 based system (with the server
part running on the Linux system)...

##------------------------------------------------------------------------------
#!/usr/local/bin/perl -w
use strict;
use vars qw/$sock $msg/;

use IO::Socket;

my $app_mode = $ARGV[0] || '-c';

if (lc($app_mode) eq '-c') {
print "Entering Client mode...\n\n";

$sock = new IO::Socket::INET(
LocalHost => '0.0.0.0', # Manually set the client's origion
addr/port
LocalPort => '3051',
PeerAddr => '192.168.0.255',
PeerPort => '3050', # Port the udp server listens on
Proto => 'udp',
Broadcast => 1 # Not sure if this is needed, I know the sockopt is
) || die "[ERROR] $!\n";
$sock->sockopt(SO_BROADCAST, 1);
print $sock "test\n";
}

# [snipped rest]
# ('else' it acts as a server lisening on UDP port 3050.)
##------------------------------------------------------------------------------

But on my linux system (RH 7.3) I get "permission denied" from $! when I
try to create the socket. (Running the server part on the Win32 box,
though the lcient on the linux never gets passed the "new
IO::Socket::INET" statement.

$ ./udptest.pl -c
Entering Client mode...

[ERROR] Permission denied

And I tried logging in as root (su - root and even hitting alt+ctrl+F1
and lgging in as root from there.) Either way I get the same result.

Is there a simple way around this, without enabling something in the
kernel or so, as I want this program to send to an entire network and be
portable.

Thanks for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top