Hello Tahir,
good catch :)
I've added this possibility with last commit.
please use:
server.getPortLowLevel();
WBR,
Alexey.
Tahir Hashmi wrote:
> Hi!
>
> While instantiating a SelectorThread, if we setPort(0), then the
> server gets started on a system assigned port. However, when getPort()
> is called on the server after successfully starting it, it returns 0.
> How can I get the actual port on which the server is listening?
>
> I tried the following but it didn't work:
>
> SelectorThread server = new SelectorThread();
> server.setPort(0);
> server.start();
>
> int port = server.getProcessorTask().getSocket().getLocalPort();
>
> However, getSocket() returns null and an NPE results. Is there an
> alternative way to do this?
>
> Thanks
>