Jonathan Livni
Jonathan Livni

Reputation: 107102

IPC port ranges

IPC can be done via TCP/IP sockets. Which port ranges should I use for local IPC between programs under windows?
Does it matter which Windows version I'm using?
In case I'd like to be cross-platform compatible, is it any different under Linux?
Does it matter what language I write in?
Does it matter if the IPC is local or not?

Upvotes: 4

Views: 6482

Answers (2)

Harry Johnston
Harry Johnston

Reputation: 36318

In principle, if your program is going to be used widely, you should get a port number assigned to you by IANA as per RFC6335. If you don't qualify for an assignment your program should choose an unused port in the 49152-65535 range at run-time and communicate this port number to the other processes by some other means.

In practice, you can usually get away with using any infrequently-used port in the range 1024-49151, although you should allow for the possibility that another program will be using it. Typically this is done by allowing the user to configure use of a different port, e.g., you could use a registry setting.

Assigned port numbers can be viewed at IANA. This list may be helpful in avoiding ports that are particularly likely to be in use.

For the record, on Windows it is usually simpler to use some other IPC method such as named pipes.

Upvotes: 3

Jim Lewis
Jim Lewis

Reputation: 45075

You should avoid using ports 0 through 1023, if your software is intended to be usable by unprivileged (non-root) users under Linux or other Unix-like platforms.

The programming language used, or OS version (within a single family, like Windows or Linux) shouldn't restrict your choice of port numbers to use for IPC.

Upvotes: 1

Related Questions