How should I choose a port number for my server?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I write a multi-homed server?

1271


What is the difference between SO_REUSEADDR and SO_REUSEPORT?

1349


What is active unix domain sockets?

541


How is a socket created?

505


What is the difference between a socket and a port?

458






What is a socket set used for?

493


What is difference between socket and websocket?

474


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

966


How do I convert a string into an internet address?

902


Why does the sockets buffer fill up sooner than expected?

988


How many sockets can a cpu have?

490


What is sae socket?

430


How many socket connections can a server handle?

464


How does a socket work?

487


Why does it take so long to detect that the peer died?

1142