Subject: | POE::Component::Server::TCP - Port does not default |
The documentation says Port defaults to INADDR_ANY. In fact Port
doesn't default at all; if Port isn't specified the constructor dies.
In addition, INADDR_ANY doesn't actually work (judging from my testing).
0, however, does, as evidenced by a few regression tests in the test
suite. Therefore I've attached a patch; it defaults Port to 0 if it
isn't specified, and updates the documentation to reflect this.
Subject: | default-port-to-0.patch |
--- TCP.pm-orig 2009-07-13 19:53:08.000000000 -0800
+++ TCP.pm-mod 2009-07-13 20:06:41.000000000 -0800
@@ -36,9 +36,6 @@
croak "$mi requires an even number of parameters" if (@_ & 1);
my %param = @_;
- # Validate what we're given.
- croak "$mi needs a Port parameter" unless exists $param{Port};
-
# Extract parameters.
my $alias = delete $param{Alias};
my $address = delete $param{Address};
@@ -47,6 +44,8 @@
my $domain = delete($param{Domain}) || AF_INET;
my $concurrency = delete $param{Concurrency};
+ $port = 0 unless defined $port;
+
foreach (
qw(
Acceptor Error ClientInput ClientConnected ClientDisconnected
@@ -950,7 +949,7 @@
=head4 Port
C<Port> contains the port the listening socket will be bound to. It
-defaults to INADDR_ANY, which usually lets the operating system pick a
+defaults to 0, which usually lets the operating system pick a
port at random.
Port => 30023