Skip to content

Commit

Permalink
Added BindAddress and BindPort support, allowing client connections to
Browse files Browse the repository at this point in the history
come from specific interfaces on a multi-host system.
  • Loading branch information
rcaputo committed Aug 30, 2002
1 parent 9d0561c commit 4028069
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/POE/Component/Client/TCP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ sub new {
unless exists $param{RemotePort};

# Extract parameters.
my $alias = delete $param{Alias};
my $address = delete $param{RemoteAddress};
my $port = delete $param{RemotePort};
my $domain = delete $param{Domain};
my $alias = delete $param{Alias};
my $address = delete $param{RemoteAddress};
my $port = delete $param{RemotePort};
my $domain = delete $param{Domain};
my $bind_address = delete $param{BindAddress};
my $bind_port = delete $param{BindPort};

foreach ( qw( Connected ConnectError Disconnected ServerInput
ServerError ServerFlushed
Expand Down Expand Up @@ -129,6 +131,8 @@ sub new {
( RemoteAddress => $address,
RemotePort => $port,
SocketDomain => $domain,
BindAddress => $bind_address,
BindPort => $bind_port,
SuccessEvent => 'got_connect_success',
FailureEvent => 'got_connect_error',
);
Expand Down Expand Up @@ -258,6 +262,8 @@ POE::Component::Client::TCP - a simplified TCP client
POE::Component::Client::TCP->new
( RemoteAddress => "127.0.0.1",
RemotePort => "chargen",
BindAddress => "127.0.0.1",
BindPort => 8192,
Domain => AF_INET, # Optional.
Connected => \&handle_connect,
Expand Down Expand Up @@ -337,6 +343,14 @@ TCP client component from other sessions. The most common use of
Alias is to allow a client component to receive "shutdown" and
"reconnect" events from a user interface session.
=item BindAddress
=item BindPort
Specifies the local interface address and/or port to bind to before
connecting. This allows the client's connection to come from specific
addresses on a multi-host system.
=item ConnectError
ConnectError is an optional callback to handle SocketFactory errors.
Expand Down
1 change: 1 addition & 0 deletions tests/29_sockfact6.t
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ POE::Component::Client::TCP->new
( RemoteAddress => '::1',
RemotePort => $tcp_server_port,
Domain => AF_INET6,
BindAddress => '::1',
Connected => \&client_got_connect,
ServerInput => \&client_got_input,
ServerFlushed => \&client_got_flush,
Expand Down

0 comments on commit 4028069

Please sign in to comment.