This program works with IO::Socket::INET:
$ cat server.pl
use strict;
use warnings;
use Socket;
require IO::Socket::INET;
my $l = IO::Socket::INET->new(Type => Socket::SOCK_STREAM);
$l->listen(5);
printf "Connect to %d\n", $l->sockport;
while (my $s = $l->accept()) {
print $s "Hi\n";
$s->close
};
__END__
$ /usr/local/blead/bin/perl5.19.8 server.pl
Connect to 60619
and then in another window:
$ telnet localhost 60619
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Hi
Connection closed by foreign host.
$ telnet localhost 60619
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Hi
Connection closed by foreign host.
If I replace IO::Socket::INET with IO::Socket::IP, then it fails:
$ diff -u server.pl server-IP.pl
--- server.pl 2014-01-09 16:56:07.000000000 +0100
+++ server-IP.pl 2014-01-09 16:57:55.000000000 +0100
@@ -2,9 +2,9 @@
use warnings;
use Socket;
-require IO::Socket::INET;
+require IO::Socket::IP;
-my $l = IO::Socket::INET->new(Type => Socket::SOCK_STREAM);
+my $l = IO::Socket::IP->new(Type => Socket::SOCK_STREAM);
$l->listen(5);
printf "Connect to %d\n", $l->sockport;
$ /usr/local/blead/bin/perl5.19.8 server-IP.pl
Can't call method "listen" on an undefined value at server-IP.pl line 8.
This isn't documented in IO::Socket::INET INCOMPATIBILITES
Is it supposed to work?
Or should it be documented?
(This is with blead on OS X, but seems to be the same behaviour with
v5.18.2 on Linux, In both cases IO::Socket:IP 0.24)
Nicholas Clark