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

Discussion in 'Perl Misc' started by Snail, Mar 9, 2005.

  1. Snail

    Snail Guest

    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 => '', # Manually set the client's origion
    LocalPort => '3051',
    PeerAddr => '',
    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.

    $ ./ -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

    Thanks for any help.
    Snail, Mar 9, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.