Home : Course Map : Chapter 13 :
Ports
JavaTech
Course Map
Chapter 13

Network Overview
Internet Basics
IP - Datagrams
  TCP - UDP
  Application Layer
Ports
Java Networking
URL
  Demo 1
Read From URL
  Demo 2
InetAddress
  Demo 3   Demo 4
Sockets
  Demo 5
Client-Server

RMI
Exercises

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

While the IP address will get the packet to the right computer, how does the packet get to the right program? A computer might have:

  • Several programs running at the same time
  • Several programs trying to communicate via the Internet
  • All the programs communicating out the same physical ethernet cable

The Port number is the key for organizing all of this. The packets are guided to the correct program by the operating system according to the port number as indicated in this diagram:.

The port is a 16-bit number. It is occasionally seen on Web addresses:

    http://www.someplace.com:80/

where 80 is the default for the HTTP server. Nowadays the port number is seldom included in the URL since the default is almost always used.

Various applications using particular protocols use standard port values as shown in tthe above diagram. Unix machines reserve ports 1-1023 for standard services. Windows machines do not restrict the use of these ports but to make your Java programs portable, it is wise to use port values above 1023.

One type of firewall assigns port numbers to the machines behind its shield. Incoming packets all go to the same IP address but with different port numbers according to the machine they are destined for. This both reduces the exposure and accessibility to the machines and reduces the need for universally unique IP numbers. Behind the firewall, the local addresses can be the same as in other LANs since the LANs are isolated from each other.

This is one of the reasons that four bytes remain sufficient for the internet despite the explosion in the number of devices with IP addresses. (Nevertheless, a sixteen byte version of IP addressing called IPv6 will gradually take over.)

 

 

Latest update: Dec. 8, 2004

  
  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.