Addresses
Also referred to as IP addresses, come in the form of a 32-bit number that looks like this: 243.37.126.82. You're probably more familiar with the symbolic form of IP addresses, which looks like this: sams.mcp.com.
| New Term |
An IP address is a 32-bit number that uniquely identifies each computer physically attached to the Internet. |
Each Internet computer has an address for the same reason you have a mailing address and a phone number at your home: to facilitate communication.
Protocols
Your mailing-address essentially revolves around one type of communication: the postal carrier driving up to your mailbox and placing the mail inside. The problem is that there are many different types of communication that can take place on the Internet, meaning that there must be an equal number of mechanisms for handling them. It's at this point that the mailing-address comparison to Internet addressing breaks down.
| New Term |
A protocol is a set of rules and standards defining a certain type of Internet communication. |
The concept of a protocol is not groundbreaking or even new. We use protocols all the time in everyday situations; we just don't call them protocols. Think about how many times you've been involved in this type of dialogue:
"Hi, may I take your order?"
"Yes, I'd like the grilled salmon and a frozen strawberry margarita."
"Thanks, I'll put your order in and bring you your drink."
"Thank you, I'm famished."
Although this conversation might not look like anything special, it is a very definite social protocol used to place orders for food at a restaurant. Conversational protocol is important because it gives us familiarity and confidence in knowing what to do in certain situations.
Without a doubt, the protocol getting the most attention these days is HTTP, which stands for Hypertext Transfer Protocol. HTTP is the protocol used to transfer HTML documents on the Web. Another important protocol is FTP, which stands for File Transfer Protocol. FTP is a more general protocol used to transfer binary files over the Internet. Each of these protocols has its own unique set of rules and standards defining how information is transferred, and Java provides support for both of them.
| New Term |
HTTP stands for Hypertext Transfer Protocol, which is the protocol used to transfer HTML documents on the Web. |
| New Term |
FTP stands for File Transfer Protocol, which is the protocol used to transfer files across the Internet. |
Ports
Internet protocols make sense only in the context of a service. For example, the HTTP protocol comes into play when you are providing Web content (HTML pages) through an HTTP service. There is a problem, however, in that the type of service must be known before information can be transferred. This is where ports come in. A port is a software abstraction that provides a means to differentiate between network services. More specifically, a port is a 16-bit number identifying the different services offered by a network server.
| New Term |
A port is a 16-bit number that identifies each service offered by a network server. |
Each computer on the Internet has a bunch of ports that can be assigned different services. To use a particular service and therefore establish a line of communication via a particular protocol, you must connect to the correct port. Ports are numbered, and some of the numbers are specifically associated with a type of service. Ports with specific service assignments are known as standard ports, meaning that you can always count on a particular port corresponding to a certain service. For example, the FTP service is located on port 21, so any other computer wanting to perform an FTP file transfer would connect to port 21 of the host computer. Likewise, the HTTP service is located on port 80, so any time you access a Web site, you are really connecting to port 80 of the host using the HTTP protocol behind the scenes. Figure 1 illustrates how ports and protocols work.
Figure 1: The relationship between protocols and ports.
All standard service assignments are given port values below 1024. This means that ports above 1024 are considered available for custom communications, such as those required by a Java client/server program implementing its own protocol. Keep in mind, however, that other types of custom communication also take place above port 1024, so you might have to try a few different ports to find an unused one.
The Client/Server Paradigm
So far I've managed to explain a decent amount of Internet networking fundamentals while dodging a major issue: the client/server paradigm. Conceptually, client/server computing is as simple as a client asking for information and a server returning it.
In the context of the Internet, clients are typically run on desktop or laptop computers attached to the Internet looking for information, whereas servers are typically run on larger computers with certain types of information available for the clients to retrieve. The Web itself is made up of a bunch of computers that act as Web servers; they have vast amounts of HTML pages and related data available for people to retrieve and browse. Web clients are used by those of us who connect to the Web servers and browse through the Web pages. In this way, Netscape Navigator is considered client Web software. Take a look at Figure 2 to get a better idea of the client/server arrangement.
Figure 2: A Web server with multiple clients connected.
Sockets
One of Java's major strong suits as a programming language is its wide range of network support. Java has this advantage because it was developed with the Internet in mind. The result is that you have lots of options in regard to network programming in Java.
Even though there are many network options, most Java network programming uses a particular type of network communication known as sockets.
| New Term |
A socket is a software abstraction for an input or output medium of communication. |
Java performs all of its low-level network communication through sockets. Logically, sockets are one step lower than ports; you use sockets to communicate through a particular port. So a socket is a communication channel that enables you to transfer data through a certain port. Figure 3 shows communication taking place through multiple sockets on a port.
Figure 3: Multiple sockets communicating through a port.
This figure brings up an interesting point about sockets: Data can be transferred through multiple sockets for a single port. This makes sense because it is common for multiple Web users to retrieve Web pages from a server via port 80 (HTTP) at the same time. Java provides basic socket classes to make programming with sockets much easier. Java sockets are broken down into two types: datagram sockets and stream sockets.