Which ports to use on a self-written tcp server

I am about to write tcp-server for a project my company is working on. The server will use several port for different tasks. During development we use just some portnumber we like: 1400, 1500, 1600-1650.

Could we use this ports on our production server? Or are there some security and / or compatibility issues we have to think about?


Solution 1:

As mentioned by Paul, ports <1024 are generally reserved for 'core' services. (Also, many operating systems require services that bind to ports <1024 to be run as root).

However, there are other ports that are commonly in use. The IANA Port number list is normally a good place to look; you should try and avoid using any port on there that is already reserved. Although, practically, this only makes a difference if you are going to be using a service that has a reserved port within your network/on your servers, checking this list is a good habit to get in to whenever you are developing a new network application.

Solution 2:

Do not design your software to use any port below 49152 by default, since these are reserved by IANA (even those unassigned). The user may be able to set a port manually during configuration. If you have to ship the software with a default port preconfigured, use some port from the range 49152 through 65535.