Is there any way by which i can find out free port on the server by executing a code from client computer.
Example for opening a port on my local machine:
ServerSocket localmachine = new ServerSocket(0);
int port = localmachine.getLocalPort();
This way I can retrieve a free port on my local machine.
Now suppose I have my own server: http://xyz.com
How can I get a free port for the server by running a program from client?
Basically I want to initiate a socket connection between client and a server. Which will be further used for communication purpose.