Chapter 13. Network Clients
Introduction
Java can be used to write many types of networked programs. In traditional socket-based code, the programmer is responsible for structuring the interaction between the client and server; the TCP “socket” code simply ensures that whatever data you send gets to the other end. In higher-level types, such as RMI, CORBA, and EJB, the software takes over increasing degrees of control. Sockets are often used for connecting to “legacy” servers; if you were writing a new application from scratch, you’d be better off using a higher-level service.
It may be helpful to compare sockets with the telephone system. Telephones were originally used for analog voice traffic, which is pretty unstructured. Then it began to be used for some “layered” applications; the first widely popular one was facsimile transmission, or fax. Where would fax be without the widespread availability of voice telephony? The second wildly popular layered application historically was dial-up TCP/IP. This coexisted with the Web to become popular as a mass-market service. Where would dial-up IP be without widely deployed voice lines? And where would the Internet be without dial-up IP?
Sockets are layered like that too. The Web, RMI, JDBC, CORBA, and EJB are all layered on top of sockets. HTTP is now the most common protocol, and should generally be used for new applications when all you want is to get data from point b to point a.
Ever since the alpha release of Java (originally as a sideline ...
Get Java Cookbook, 3rd Edition 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.