Java Reference
In-Depth Information
Figure 13.2 A packet
arrives from the network
and goes to the port to
which it is addressed.
The port number is the key for organizing all this. The packets are guided by
the operating system to the correct program according to the 16-bit port num-
ber. Casual internet users occasionally encounter port numbers when they are
appended to web addresses, as in:
http://www.myschool.edu:80/
Port 80 is the default port for the HTTP server so nowadays it is seldom included
in the URL. Some popular web servers, notably the open source Tomcat server,
commonly use port 8080 by default. So a URL address might appear as
http://www.myschool.edu:8080/
Various other applications for particular protocols use standard port values as
shown in Figure 13.2. Unix machines reserve ports 1-1023 for privileged services
(i.e. owned by the Unix root account). Windows machines do not restrict these
ports but in order to make your Java programs portable it is wise to choose 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 4 bytes remain sufficient for the Internet despite the explosion in the number
of devices with IP addresses. (Nevertheless, a 16-byte version of IP addressing
called IPv6 will gradually take over.)
13.4 Java networking
Java was designed from the start with networking in mind. Java first became
famous because of applets, which were invented to provide dynamic content to
Search WWH ::




Custom Search