How should I choose a port number for my server?



How should I choose a port number for my server?..

Answer / chaitanya

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.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Unix Socket Programming Interview Questions

Why do we need sockets?

0 Answers  


What is socket programming in java?

0 Answers  


Why does connect() succeed even before my server did an accept()?

1 Answers  


What is a socket api?

0 Answers  


Can multiple sockets use the same port?

0 Answers  






How do I use TCP_NODELAY?

0 Answers  


Is tcp or unix socket faster?

0 Answers  


What are the pros/cons of select(), non-blocking I/O and SIGIO?

0 Answers  


How can I bind() to a port number < 1024?

1 Answers  


How can I find the full hostname (FQDN) of the system I am running on?

1 Answers  


Can a single socket port be used for multiple applications?

0 Answers  


Can a socket have multiple ports?

0 Answers  


Categories