Reputation: 1
#!/usr/bin/perl
use warnings; use strict;
use IO::Socket::INET;
our $local_host = "0.0.0.0";
our $local_port = "14267";
$SIG{'CHLD'} = 'IGNORE';
my $bind = IO::Socket::INET->new(
Listen=>5,
LocalAddr=>$local_host.':'.$local_port,
ReuseAddr=>1)
or die print('Could not bind: ' .$local_host.':'.$local_port);
When I try to execute this code from terminal it works, but when I try to execute it from browser it return could not bind etc.
Someone can explain to me what the problem is? It is not about user privileges I think.
Upvotes: 0
Views: 466
Reputation: 385590
How could you possibly know it couldn't bind? You always log "Could not bind" no matter what error occurred! More importantly, you don't log what error occurred! The first step would be to correct that.
#!/usr/bin/perl
use warnings; use strict;
use IO::Socket::INET;
my $local_port = 14267;
my $server_socket = IO::Socket::INET->new(
LocalPort => $local_port,
Listen => 5,
ReuseAddr => 1,
)
or die("Can't create server socket: $@"); # <-- The relevant change.
I suspect you'll get some kind of permission error because of a security framework like SElinux.
Upvotes: 3