From cc90b70041fcf3da68be90a11535cc25f8dd089e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hinrik=20=C3=96rn=20Sigur=C3=B0sson?= Date: Sun, 22 May 2011 06:37:34 +0000 Subject: [PATCH] Document using getsockname to verify a listening socket --- lib/POE/Wheel/SocketFactory.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/POE/Wheel/SocketFactory.pm b/lib/POE/Wheel/SocketFactory.pm index c93463aeb..be06828c2 100644 --- a/lib/POE/Wheel/SocketFactory.pm +++ b/lib/POE/Wheel/SocketFactory.pm @@ -1443,7 +1443,20 @@ to which POE::Wheel::SocketFactory has bound its listening socket. Test applications may use getsockname() to find the server socket after POE::Wheel::SocketFactory has bound to INADDR_ANY port 0. -Z +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