My tomcat(4.0.1)is running on Port:8080 and Port:80 .I want to know why it is running on Port 8080 and 80 why not 10,20,50,70,60,1000,2000 etc.My weblogic server are running on Port:7001 and Java web server on Port:8080.I know that we can change the port number by modifing the configuration files of all server for example tomcat server.xml.Actually I want to know how peoples are fix the port numbers(what concept behind it).For fixing the port numbers what factors should be consider.
Originally posted by Manish Hatwalne:
Port numbers below 1024 are reserved, and generally should not be used for any non-standard services. You can read more abt all this in Douglous Comer's books series.
Just because ports are reserved does not mean you can't use them or that you need to use them for the reserved purpose.
If I want to run SMTP (typically port 25) over port 443(HTTPS) then I happily can. The problems arises from the fact that firewalls and most clients will be expecting traffic on 443 to be HTTPS traffic and not SMTP traffic.
The reason that Tomcat is running on port 80 is because someone (you?) decided to use the default HTTP port which is perfectly fine, especially since Tomcat generates HTTP traffic. The main benefit to doing this is two fold: 1) it is firewall friendly and 2) users don't need to specify the port number in their browser.
[ October 21, 2002: Message edited by: Chris Mathews ]
I think all of u r not getting my point what actually i want to know.I want to know upon what factors Port numbers are decided or I can decide any numbers for Port just like 5,7,10,20,23,24 etc. or Is there any restriction or any rules for selecting Port Numbers for any server it may be Tomcat or Weblogic or Java web server.
Originally posted by Bikash Paul:
I want to know upon what factors Port numbers are decided or I can decide any numbers for Port just like 5,7,10,20,23,24 etc. or Is there any restriction or any rules for selecting Port Numbers for any server it may be Tomcat or Weblogic or Java web server.
You can decide to use the port number you want. You dont have any restrictions, but as the previous messages said, the ports under 1024 are reseved for some default behaviours, so you can make use of it to make things easier:
For instance, lets say HTTP: you can set your http server in the 67243 port(its not mandatory to use any concrete port), but then, people connectinng to your webserver will have to know that number in order to write it in the address bar of the browser http://yourip:67243/ . As the http default port is 80, the applications dealing with http (as your browser) point directly to that port, so if you set your web server to listen through the 80, people will connect to you just with http://yourip/
you should also be aware that if you use a port<1024 it may cause you conflicts if it is been used for any system application/process: 25 for mail server, 21 for ftp, etc...
So although you "don't have" restrictions, typically you will use <1024 ports for their standard/default uses, and >1024 ports for your ad-hoc apps.
Here is a link to the first volume of D Comer's book. There are 3 volumes and if you read and understand all 3, there's nothing more to networking!
1. General info about use of ports < 1024.
In the dim early ages of TCP/IP, it was thought that one way to make systems more secure was to place the "dangerous" services in a zone where only an administrative (root) user could use them. Thus, in many OS's, if I found that the main webserver on port 80 wasn't up, I could try, as an ordinary user, to startup a bogus webserver, but my bogus server wouldn't be allowed to start because access to port 80 was denied.
A related condition is that since many servers operate in a many-clients/one-server mode, the server port number is fixed so that it can be easily found, but each client is using a (high-numbered) dynamically-assigned port ID. So these ports can be assigned attributes more appropriate to clients.
2. The whole concept of which port number to use is based on convention. When you specify a URL beginning with "http:", for example, your computer's resolver knows that unless you specifically supply a port number, Port 80 is the port you mean. This is known as a "Well-Known Port Number", and you can find lists of them with any Internet search engine. The Well-Known port is just a convention, however, and (subject to the <1024) rule and whatever firewalls may be in the way) actually any port number can be used.
Conventionally, while the main http port is port 80, certain alternative ports are common for secondary servers and test servers. For HTTP, ports 8000, 8008, 8080, and 8180 are popular. Since Tomcat is often paired with Apache, a common configuration is to have Tomcat serve HTTP on port 8080 or 8180 for test and debug purposes, but have Apache forward production requests which were made through port 80.
Note that Tomcat, like many servers, is not limited to using only one port. You can add and/or change ports and services in the Tomcat server.xml file.