PDA

View Full Version : 4.10 - How should I choose a port number for my server?


Loco
07-26-2002, 11:13 PM
4.10 - How should I choose a port number for my server?

The list of registered port assignments can be found in STD 2 or RFC 1700. Choose one that isn't already registered, and isn't in /etc/services on your system. It is also a good idea to let users customize the port number in case of conflicts with other un-registered port numbers in other servers. The best way of doing this is hardcoding a service name, and using getservbyname() to lookup the actual port number. This method allows users to change the port your server binds to by simply editing the /etc/services file.

From: Stephen Satchell

In the course of researching this question, I found a reference in some BSD documentation that port numbers from 48K to 64K should be used by applications for well-known-socket numbers. So in an application I wrote, I used 54001 as the well-known port.
Wouldn't you know, I found a TCP/IP product that wouldn't allow me to use that number! That product (name withheld to protect the guilty) allows socket numbers from zero to 32768. (NOT 32767, the usual boundry condition. Surprised me, it did.) So I provided for setting an alternate port address for those people using the *** ******* products. Other products worked just fine with 54001.

From: Charles E. Campbell, Jr

If you plan to distribute your server, you should consider registering your server with IANA (http://www.iana.org/)

From: Warren Nash

look in /etc/services or choose an number above 1024.