Meaningless Drivel is fun!*
The moose likes Sockets and Internet Protocols and the fly likes can we use same port(exp 80) if we use different protocols Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "can we use same port(exp 80) if we use different protocols" Watch "can we use same port(exp 80) if we use different protocols" New topic
Author

can we use same port(exp 80) if we use different protocols

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1109
i need to know can we use same port(exp 80) if we use different protocols(HTTP and FTP)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18825
    
  40

sam liyanage wrote:i need to know can we use same port(exp 80) if we use different protocols(HTTP and FTP)


When you say "use the same port", do you mean for two applications to try to bind to the same local port? Do you do mean for two applications to try to use the same remote port? Do you mean a single server binding to the same port, but serving two different protocols? Etc. We need a bit of clarification please.

Henry
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1109
i found below in JSP & SERVLET book.please explain

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 if the apps use different protocols)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18825
    
  40

sam liyanage wrote:i found below in JSP & SERVLET book.please explain

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 if the apps use different protocols)


I believe that the "protocol" being referred to here is the transport level protocol -- meaning either "TCP" or "UDP".

And yes, it is supposedly possible. Never tried it myself though. If you want to confirm it, it should be straightforward to test -- just create a ServerSocket and a DatagramSocket using the same local bind port.

Henry
 
Don't get me started about those stupid light bulbs.
 
subject: can we use same port(exp 80) if we use different protocols