O'Reilly logo

Java RMI by William Grosso

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Special-Purpose Sockets

Socket and ServerSocket are object-oriented wrappers that encapsulate the TCP/IP communication protocol. They are designed to simply pass data along the wire, without transforming the data or changing it in any way. This can be either an advantage or a drawback, depending on the particular application.

Because data is simply passed along the network, the default implementation of Socket is fast and efficient. Moreover, sockets are easy to use and highly compatible with existing applications. For example, consider the WebBrowser application discussed earlier in the chapter. We wrote a Java program that accepted connections from an already existing application (in our case, Netscape Navigator) that was written in C++.

There are, however, two important potential downsides to simply passing along the data:

  • The data isn’t very secure.

  • Communications may use excessive bandwidth.

Security is an issue because many applications run over large-scale networks, such as the Internet. If data is not encrypted before being sent, it can easily be intercepted by third parties who are not supposed to have access to the information.

Bandwidth is also an issue because data being sent is often highly redundant. Consider, for example, a typical web page. My web browser has 145 HTML files stored in its cache. The CompressFile application from Chapter 1, on average, compresses these files to less than half their original size. If HMTL pages are compressed before being sent, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required