S
sc_wizard29
hi everyone,
This ones makes me scratch my head : I'm using the following script on
Windows and it looks like I can run two instances of it
simultaneously...which means that I have 2 servers listening on the
same port.
#!/usr/bin/perl -w
use strict;
use Socket;
my $port = 8080;
my $proto = getprotobyname('tcp');
socket(Server, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) || die
"setsockopt: $!";
bind(Server, sockaddr_in($port, INADDR_ANY)) || die "bind: $!";
listen(Server,SOMAXCONN) || die "listen: $!";
print "Server : server started on port $port\n";
while(1) {}
I was expecting an error like "port already in use". Am I doing
something wrong ?
This ones makes me scratch my head : I'm using the following script on
Windows and it looks like I can run two instances of it
simultaneously...which means that I have 2 servers listening on the
same port.
#!/usr/bin/perl -w
use strict;
use Socket;
my $port = 8080;
my $proto = getprotobyname('tcp');
socket(Server, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) || die
"setsockopt: $!";
bind(Server, sockaddr_in($port, INADDR_ANY)) || die "bind: $!";
listen(Server,SOMAXCONN) || die "listen: $!";
print "Server : server started on port $port\n";
while(1) {}
I was expecting an error like "port already in use". Am I doing
something wrong ?