This should work:

use Socket 'unpack_sockaddr_in';
...
my $listener = $_[HEAP]{listener};
my ($port, $addr) = unpack_sockaddr_in($listener->getsockname);


Regards,
Ciprian

On Fri, Oct 7, 2011 at 11:24 PM, Cary Lewis <cary.le...@gmail.com> wrote:

> I want to create a TCP server that allocates a random TCP port - this is
> done by specifying port 0, but how do I determine which port has been
> allocated, prior to a client connecting to it?
>
> I need to set up some other configuration based on the port, so I need it
> right after the port is allocated.
>
> I am using POE::Component::Server::TCP
>
> Thanks.
>

Reply via email to