13

I'm creating an internal collaboration tool that will use a central server (on an intranet) and one or more ports for socket communication to clients. I know that many ports are reserved for particular purposes and others are conventionally used for certain types of traffic.

How should I go about picking a default port that is least likely to have been "claimed" by someone else for their tool? Is there a database that identifies all known (even unconventional) port usage?

Jace Browning
  • 233
  • 2
  • 6
  • 3
    This is generally only an issue if something is already using the port on the server. However, the port should be configurable. I've seen quite a lot of software have hardcoded ports, which is not what you want. – devicenull Jul 04 '14 at 01:51
  • @devicenull I'll definitely have the option to override the default. – Jace Browning Jul 04 '14 at 02:12
  • 3
    If your beard is gray enough, you could use RPC and register your own endpoint. http://msdn.microsoft.com/en-us/library/windows/desktop/aa379441(v=vs.85).aspx – Ryan Ries Jul 04 '14 at 02:38
  • 2
    Unless you have a great reason not to it is better to use existing protocols where you can. a) It is natural to think you can do a better job, for most people that is not true. But even when you can, is it better enough to counteract b) network tools/devices are already setup to work with existing standards. Adding new ones has a barrier and amount of work to do to implement. – JamesRyan Jul 04 '14 at 11:08
  • 2
    For something that is internal collaboration anything > 1024 and < 32768 (should protect against ephemeral port bindings) and NOT listed in the IANA port registry would be OK, providing you communicate effectively to your internal depts you have taken the port. – Matthew Ife Jul 04 '14 at 19:21

2 Answers2

16

Yes, IANA maintains the official service and port number registry.

The process for getting a port number assigned to you is documented in RFC 6335. A review process is required for any port assignment, but it is much stricter for ports < 1024; such assignments require (among other things) that your protocol is documented in an RFC.

(Note that this process is relatively new and that there are many assigned ports which were grandfathered in.)

For < 1024, ports 1021 and 1022 are reserved for experimentation; above that, for experimentation you can simply use a dynamic port >= 49152.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • 1
    Shortcut to search for "unassigned": http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=Unassigned – Jace Browning Aug 09 '14 at 23:20
3

In most cases it is better to just use HTTP, as sooner or later there will be a firewall you need to cross. Most OSs allow the HTTP address space to be divided up between processes.

Ian Ringrose
  • 870
  • 1
  • 6
  • 12
  • 3
    I'm confused, can't I use HTTP over any port? I don't want to default to `:80` or `:8080` because there is a strong possibility those will already be in use. Isn't my question still valid? – Jace Browning Jul 04 '14 at 15:50
  • @JaceBrowning, yes you can, but using any other port is just a odd bit of history :-). Any decent OS, will let you divide up the HTTP namespace between applications. – Ian Ringrose Jul 04 '14 at 22:52