Re: Quick question

Ciprian Hacman <[email protected]> Sat, 8 Oct 2011 09:51:46 +0300
Newsgroups gmane.comp.lang.perl.poe
Message-ID <CAOcN+pCMT08a8Q3FpegK1NW73eQLuaY1Y_rPMJpNUzFUr3-hAw@mail.gmail.com>
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 <[email protected]> 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.
>