Java Reference
In-Depth Information
chapter 1
Introduction
M illions of computers all over the world are now connected to the worldwide network
known as the Internet. The Internet enables programs running on computers thousands of
miles apart to communicate and exchange information. If you have a computer connected to a
network, you may have used a Web browser—a typical program that makes use of the Internet.
What does such a program do to communicate with others over a network? The answer varies
with the application and the operating system (OS), but a great many programs get access to
network communication services through the sockets application programming interface (API).
The goal of this topic is to get you started writing Java programs that use the sockets API.
Before delving into the details of the API, it is worth taking a brief look at the big picture
of networks and protocols to see how an API for Transmission Control Protocol/Internet
Protocol fits in. Our goal here is not to teach you how networks and TCP/IP work—many fine
texts are available for that purpose [2, 4, 11, 16, 22]—but rather to introduce some basic
concepts and terminology.
1.1
Networks, Packets, and Protocols
A computer network consists of machines interconnected by communication channels. We
call these machines hosts and routers . Hosts are computers that run applications such as your
Web browser. The application programs running on hosts are really the users of the network.
Routers are machines whose job is to relay, or forward , information from one communication
channel to another. They may run programs but typically do not run application programs. For
our purposes, a communication channel is a means of conveying sequences of bytes from one
host to another; it may be a broadcast technology like Ethernet, a dial-up modem connection,
or something more sophisticated.
Routers are important simply because it is not practical to connect every host directly
to every other host. Instead, a few hosts connect to a router, which connects to other routers,
and so on to form the network. This arrangement lets each machine get by with a relatively
1
 
Search WWH ::




Custom Search