Java – How to decide which port to use in socket communication

How to decide which port to use in socket communication… here is a solution to the problem.

How to decide which port to use in socket communication

I’m going to write a socket communication program to do that
Interprocess communication.

I know I need to have a client and server implementation.
Server implementation:

MyServerice = new ServerSocket(PortNumber);

The client and server will be on the same machine, so I don’t want to interfere with any other running applications

How do I decide which port number to use?

Solution

Take a look at this table
These are basically all that you never know if any other external application is taking up the port you want, so in your case it’s a

First-come, first-served questions

Related Problems and Solutions