wood burning stoves 2.0*
The moose likes Servlets and the fly likes Query about 'Port' Number?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Query about Watch "Query about New topic
Author

Query about 'Port' Number??

Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi all friends,
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.
Regards
Bikash
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

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.
HTH,
- Manish
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi manish,
If Port Numbers below 1024 are reserved then how my Tomcat(4.0.1) is running on Port:80.Can u plz give me the url of Douglous Comer's books series so that I can Take guide from there.
Regards
Bikash
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

I quick search of the internet gives me this.


Please ignore post, I have no idea what I am talking about.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
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.
HTH,
- Manish

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 ]
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
i guess you can change the port number you want tomcat to be connected to in the server.xml file.


Asher Tarnopolski
SCJP,SCWCD
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi all friends,
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.
Regards
Bikash
Juanjo Bazan
Ranch Hand

Joined: Feb 04, 2002
Posts: 231
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.
HTH
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Juanjo has already explained a part of the answer, you should not use ports below 1024 for non-standard services that your server may provide.
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!
Comer's book
HTH,
- Manish
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

There are 2 parts to the answer:
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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi all friends,
Now it is clear to me.Thanks for ur lots of guide.
Thanks
Bikash
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Query about 'Port' Number??