Skip to content

Commit

Permalink
added Address parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
rcaputo committed Jan 10, 2001
1 parent fa0111a commit 700c569
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions lib/POE/Component/Server/TCP.pm
Expand Up @@ -5,9 +5,10 @@ package POE::Component::Server::TCP;
use strict;

use Carp qw(carp croak);
use Socket qw(INADDR_ANY);
use vars qw($VERSION);

$VERSION = 1.00;
$VERSION = 1.01;

# Explicit use to import the parameter constants.
use POE::Session;
Expand All @@ -34,9 +35,13 @@ sub new {
croak "$mi needs an Acceptor parameter" unless exists $param{Acceptor};

# Extract parameters.
my $port = delete $param{Port};
my $address = delete $param{Address};
my $port = delete $param{Port};
my $accept_callback = delete $param{Acceptor};
my $error_callback = delete $param{Error};
my $error_callback = delete $param{Error};

# Defaults.
$address = INADDR_ANY unless defined $address;

# Complain about strange things we're given.
foreach (sort keys %param) {
Expand All @@ -54,6 +59,7 @@ sub new {
sub {
$_[HEAP]->{listener} = POE::Wheel::SocketFactory->new
( BindPort => $port,
BindAddress => $address,
Reuse => 'yes',
SuccessState => 'got_connection',
FailureState => 'got_error',
Expand Down Expand Up @@ -108,6 +114,7 @@ POE::Component::Server::TCP - a simplified TCP server
POE::Component::Server::TCP->new
( Port => $bind_port,
Address => $bind_address, # Optional.
Acceptor => \&accept_handler,
Error => \&error_handler, # Optional.
);
Expand All @@ -127,6 +134,18 @@ to accept other parameters as it evolves.
=over 2
=item Address
Address is the optional interface address the listening socket will be
bound to. When omitted, it defaults to INADDR_ANY.
Address => '127.0.0.1'
It's passed directly to SocketFactory's BindAddress parameter, and so
it can be in whatever form SocketFactory supports. At the time of
this writing, that's a dotted quad, a host name, or a packed Internet
address.
=item Port
Port is the port the listening socket will be bound to.
Expand Down

0 comments on commit 700c569

Please sign in to comment.