*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt on Protocol & Port number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt on Protocol & Port number" Watch "Doubt on Protocol & Port number" New topic
Author

Doubt on Protocol & Port number

kalle suresh
Ranch Hand

Joined: Nov 20, 2007
Posts: 48
On page 21, it was written that a port represents a logical connection to a particular piece of software running on the server hardware;
HTTP (protocol) - port 80
FTP (protocol) - port 21
Telnet(protocol) - port 23.

From the above we can observer that, there is a one-one mapping between Protocol and Port on the server. But on the same page (21), one more
statement is like "Although it is possible to run more than one app on the same port if the apps use different protocols"

If there is one-one mapping between protocol - port, how is it possible
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
From the above we can observer that, there is a one-one mapping between Protocol and Port on the server.

No. The same protocol can be used on multiple ports at the same time.

But on the same page (21), one more statement is like "Although it is possible to run more than one app on the same port if the apps use different protocols"

This is not correct. Only one particular protocol can be used on a particular port at any given time. Furthermore, only one process (i.e., application) can use a particular port at any given time.

What book is this you're quoting from?


Ping & DNS - my free Android networking tools app
kalle suresh
Ranch Hand

Joined: Nov 20, 2007
Posts: 48
Head First Servlets & JSP
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

My copy of HFSJ doesn't say that on page 21.


A good workman is known by his tools.
kalle suresh
Ranch Hand

Joined: Nov 20, 2007
Posts: 48
It is in the Chapter1 (Why user Servlets & JSP) under topic "A TCP port is just a number".
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

OK, yes it does say it in the paranths of a handwritten note.

I believe it should say:
Using one server app per port, a server can have up to 65536 different server apps running (although it's possible to run more than one app on the same port unless the apps use different protocols).

Good catch. I don't think anyone has noticed that before.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
Originally posted by Marc Peabody:
I believe it should say:
Using one server app per port, a server can have up to 65536 different server apps running (although it's possible to run more than one app on the same port unless the apps use different protocols).


I'm wondering if we're using different definitions of what a port is. Generally it's not possible to have more than one process listen to a particular port at a given time, regardless of the protocol used. To quote from Wikipedia: Ports are typically used to map data to a particular process running on a computer. (In the first paragraph - not that Wikipedia is necessarily correct, of course.)

Marc's phrasing suggests otherwise, and I'm having a hard time picturing how that would work.
Bryan Basham
author
Ranch Hand

Joined: Apr 30, 2001
Posts: 199
Hi all,

Let's be clear with our definitions. A 'port' is a number indicating the "location" of a service. A 'protocol' is mechanism by which packets are transmitted on top of the IP (Internet Protocol) layer; thus TCP and UDP are the most common examples. A 'service' or 'app' is a program responsible for processing requests from a client.

I just talked to a network engineer at my company and he said that a given port can support both a TCP and UDP process simultaneously. This is the case that is described in the book "it is possible to run multiple apps on the same port if the apps use different protocols". So, for example, you could have NTP running on port 80 over UDP and HTTP running on port 80 over TCP. Make sense?

If is not possible to run multiple apps on the same port using the same protocol. So, for example, you could not run FTP on port 80 over TCP and HTTP on port 80 over TCP. Make sense?

So, really there is one-to-one mapping between an app and the combination of port and protcol.

Relax! This has nothing to do with servlets and you will not see questions about this on the SCWCD.

Regards,
Bryan
[ March 12, 2008: Message edited by: Bryan Basham ]
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Originally posted by Bryan Basham:
If is not possible to run multiple apps on the same port using the same protocol. So, for example, you could not run FTP on port 80 over TCP and HTTP on port 80 over TCP. Make sense?

Huh? The example doesn't match the statement.

And I can run multiple apps using the same port and protocol easily if they are all in the same container.
Bryan Basham
author
Ranch Hand

Joined: Apr 30, 2001
Posts: 199
Hi Marc,

Yes, you can do that but that "container" is essentially acting as a single app that dispatches to multiple services. The key phrase here is "single app". The point of the hand-written note is that you cannot have two apps running on the same port on the same protocol.

Does that help?

-Bryan
kalle suresh
Ranch Hand

Joined: Nov 20, 2007
Posts: 48
The point of the hand-written note is that you cannot have two apps running on the same port on the same protocol

Currently in our QA environment we are using the below urls to access two different applications.

http://debitcard-qa.pronet.providian.com:7311/ClaimCreation/login.htm
http://debitcard-qa.pronet.providian.com:7311/ClaimAnalysis/login.htm

Here both the apps are using same port : 7311
same protocol: http

Could you explain me. (is it running because; as the one-one mapping between app and combination of protocol and port is different.
i.e., claimcreation - http:7311
claimanalysis - http:7311)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
As Bryan pointed out above, the misunderstanding arises from what is considered an "application". Two applications in the sense that you (and earlier Marc) were using the term -in other word, web applications- can use the same port/protocol. But the book uses the term application to mean "web server" or "servlet container" (of which you can't have two listening to the same port).

That's why I used the term "process" instead of "application" - a process is an operating system concept, and thus indicative of "web server", not "web application".

Maybe it's not too late for Bryan to clarify this in the next edition of HFSJ :-)
kalle suresh
Ranch Hand

Joined: Nov 20, 2007
Posts: 48
I'm really confused. Could you please frame the sentense.

Thanks in advance.
Bryan Basham
author
Ranch Hand

Joined: Apr 30, 2001
Posts: 199
Hi all,

Ulf is exactly right and uses better terminology than we did in the book. I have asked my editor to remove the parenthetical statement in the hand-written note on pg 21, but it might be too late. I have made this decision because it is now clear to me that the note is not clear relative to the content of the page; specifically, because the page is not clear about what type of "protocol" is meant (TCP vs UDP layer 4 as opposed to HTTP vs FTP layer 7). Furthermore, this is a rather obscure piece of knowledge that is not particularly relevant to the content of the book.

Let me try to rephrase what was meant by the note: "It is possible to run more than one OS processes on the same port only if the processes use different transport layer protocols."

The negative version of this statement might be a little more clear: "It is not possible to run two OS processes on the same port with the same transport layer protocol." Does that help?

References:
  • Network Layers (ISO Model)
  • OS process management


  • -Bryan
    kalle suresh
    Ranch Hand

    Joined: Nov 20, 2007
    Posts: 48
    Thanks a lot.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Doubt on Protocol & Port number
     
    Similar Threads
    trying to connect to another ip adress
    Is it printed wrongly?
    could anyone please answer this question.....
    a question about port
    Doubt on port in HFSJ