1

This is a question out of curiosity:

I am using a database system (kdb+), and the documentation of this system seems to be coherent in choosing to open a socket to either port 5000 or port 5001 for communication purposes.

In another part of the documentation I found a statement saying that their automatic multiprocessing command opens ports from 20000 through 20000+N-1.

I am curious to know if there is any heuristic for opening a specific port:

  • Is there a common practice for this?
  • Does it matter at all (for choosing ports above port 1024)?
  • How do you choose your ports?

The way I see it, port 2000 seems like a safe bet to make sure no other applications are using that port. But then why do code examples in other parts of the documentation seem to prefer 5000 and 5001 that much? (Wikipedia didn't help in explaining this to me)

Jean-Paul
  • 19,910
  • 9
  • 62
  • 88

1 Answers1

1

For two kdb+ databases to talk to each other via IPC at least one has to have a port set whilst the other (caller) will get given a temporary port by the OS.

So you need to know the "ephemeral port range" of the OS you are using, and avoid that range when assigning ports to databases.

Manish Patel
  • 4,411
  • 4
  • 25
  • 48
  • That makes sense. I still have some questions though: so any other ports apart from the "ephemeral port range" is fine? Does it matter at all above 1024 for Windows? Is above 2000 considered to be 'more safe' or something like that? – Jean-Paul Jan 16 '15 at 08:29
  • 1
    There's a similar question on stackoverflow re Windows here - http://stackoverflow.com/questions/218839/assigning-tcp-ip-ports-for-in-house-application-use -- Simply put, don't use the ephemeral range and also obviously ports that may be used by other processes (which, possibly, is not documented). This is the same pain anyone has to go through when using up ports for communication, just something you have to figure out in our your setup :) – Manish Patel Jan 16 '15 at 11:27
  • Thanks. I'll just pick some random ports (5000+) then. – Jean-Paul Jan 16 '15 at 11:44