is Default port numbers are always four digit in Windows/ Linux/ Mac .?
We can give our own number when customization then why all applications provide 4 digit default port numbers.?
Advertisement
Answer
Network port numbers are 2-byte unsigned integers, and as such can be any number from the range 0 to 65535. Zero is reserved but apart from that, you could theoretically use any number, except that certain ports have a very specific meaning attached to them. You can see a list of these common ports on Wikipedia. While you could absolutely use those for your application as well, chances are that they are already in use.
For custom applications you usually use one outside of the “well known” range, so a four or five digit number. Often, you should even go above 49152 into the “ephemeral” space. That way, chances for conflicts are less common, and you will not attempt to use a port that is commonly used for a specific type of application. It’s also common to randomize the port (if your application allows that), to reduce the chance for conflicts.
Another reason why a large port number is used is because operating systems may restrict opening lower port numbers. For example on Linux, you need root permissions to open a port below 1024. Opening a port number higher than that does not need root permissions though. That’s why many development web servers for example use something like 8080, 8000, or 3000.