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
--
Tahir Hashmi
http://www.codemartial.org
I have seen The Source