Chapter 18

Network Programming

Computers connected to a network can communicate with each other only if they agree on the rules of communication, called protocols, that define how to request the data, if the data should be sent in pieces, how to acknowledge received data, if the connection between two computers should remain open, and so on. TCP/IP, UDP/IP, FTP, and HTTP are some examples of network protocols.

Local area network (LAN) refers to a computer network connecting devices in a small area — the same office or house, or a rack. Interconnected computers located farther apart or that belong to different companies are part of a wide area network (WAN). The Internet consists of millions of networks and individual devices. When connected networks belong to the same organization it is referred to as an intranet. For security reasons intranets are shielded from the rest of the world by special software called firewalls.

The World Wide Web (WWW) uses uniform resource locators (URLs) to identify online resources. For example, the following URL says that there is (or will be generated on the fly) a file called training.html located at the remote host known as mycompany.com, and that the program should use the HTTP protocol to request this file. It also states that this request has to be sent via port 80.

www.mycompany.com:80/training.html

The hostname must be unique and it is automatically converted to the IP address of the physical server by your Internet service provider (ISP) ...

Get Java® Programming 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.