kingrichard2005
kingrichard2005

Reputation: 7289

Port for application listening

I have an application that I'm currently testing that listens for requests over the network on port 1025. I chose this port arbitrarily and it is easy to change, my concern is that my application will collide with other system processes listening on that port. My two primary question are as follows:

  1. Are there common system processes that use port 1025 that may conflict with my application?
  2. Assuming the answer to 1) is yes, what is another less commonly used port or range of ports my application can safely utilize?

Upvotes: 0

Views: 192

Answers (2)

enobufs
enobufs

Reputation: 930

That'll do in most cases. If you need to run more than one instance (a listener) of your application on the same IP address, for example, the port collision still occurs. To overcome this case, you may choose to bind your socket to port 0 (= any port) to have system assign the port number for you. Then you can use getsockname() (BSD socket API), or equivalents, to get the actual port number the system has assigned for the socket. Downside of it is obviously that the port number will change every time. There needs to be a way to tell (either manually, programmatically or systematically) its listening port to connectors. In fact, many VoIP/peer-to-peer applications work this way, with a help of 'rendezvous' server.

Upvotes: 0

brazilianldsjaguar
brazilianldsjaguar

Reputation: 1449

Any port in the 49152 – 65535 range cannot be registered by any company, and therefore you're more likely to not run into any problems with port conflicts.

A list of registered ports, etc. can be found at this wikipedia link here.

If you don't like Wikipedia, check this link out, from the Internet Assigned Numbers Authority (IANA).

Upvotes: 1

Related Questions