Java Reference
In-Depth Information
CHAPTER
17
Network Programming
In this chapter, I will discuss the various built-in features of the J2SE that pro-
vide support for network programming. Computer networks have become so
common that you may even have one in your own home, and almost certainly
at your place of work. Then there's the Internet, which can be pictured as one
global network of computers. For this reason, network programming is a fun-
damental and essential part of any programming language. Java, being a newer
language, has plenty of built-in classes and interfaces for network program-
ming. I will begin with an overview of networks and the two common proto-
cols: TCP and UDP. Then, I will show you how to connect two computers using
sockets, allowing them to perform TCP/IP communication. Then, I will discuss
the Java Secure Sockets Extension (JSSE), which allows for secure socket con-
nections. I will then discuss how to send and receive UDP datagram packets,
and how to use the URLConnection class to communicate with a URL.
An Overview of Network Programming
The term network programming refers to writing programs that execute across
multiple devices (computers), in which the devices are all connected to each
other using a network. The java.net package of the J2SE APIs contains a
591
Search WWH ::




Custom Search