Skip to content

Commit

Permalink
Document using getsockname to verify a listening socket
Browse files Browse the repository at this point in the history
  • Loading branch information
hinrik authored and rcaputo committed Jul 27, 2011
1 parent 18a75c2 commit cc90b70
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/POE/Wheel/SocketFactory.pm
Expand Up @@ -1443,7 +1443,20 @@ to which POE::Wheel::SocketFactory has bound its listening socket.
Test applications may use getsockname() to find the server socket Test applications may use getsockname() to find the server socket
after POE::Wheel::SocketFactory has bound to INADDR_ANY port 0. after POE::Wheel::SocketFactory has bound to INADDR_ANY port 0.
Z<TODO - Example.> Since there is no event fired immediately after a successful creation of a
listening socket, applications can use getsockname() to verify this.
use Socket 'unpack_sockaddr_in';
my $listener = POE::Wheel::SocketFactory->new(
BindPort => 123,
SuccessEvent => 'got_client',
FailureEvent => 'listener_failed',
Reuse => 'on',
);
my ($port, $addr) = unpack_sockaddr_in($listener->getsockname);
print "Socket successfully bound\n" if $port;
=head2 ID =head2 ID
Expand Down

0 comments on commit cc90b70

Please sign in to comment.