A Simple Socket-Based Client-Server Example


Introduction

Many of the software applications you use daily are based on the client-server model. A few examples include email programs and web-based applications accessed via a web browser. Email programs and web-based applications are based upon a set of well known application protocols. (Post Office Protocol (POP) and Simple Mail Transfer Protocol (SMTP) for e-mail programs, and Hypertext Transfer Protocol (HTTP) for web-based applications) There are, additionally, a multitude of custom-developed client-server applications in use throughout the world providing targeted functionality to their user base. A majority of these applications utilize custom application protocols designed specifically for the task at hand. This chapter builds upon the material presented in chapter 19 and focuses on the creation of client-server applications based on sockets and Remote Method Invocation (RMI).

The discussion begins with a review of the socket-based client-server application model originally presented in chapter 19. A simple socket-based client-server application is then presented and discussed to highlight its critical features. Following this, a significant client-server application is presented that combines the socket and RMI-based client-server models. Multi-threading techniques are utilized to allow the socket-based server to simultaneously process multiple client service requests.

The secondary focus of this chapter is on the wide-array of Java platform classes and tools that enable the creation of complex client-server applications. The DataInputStream and DataOutputStream classes will be used to send and receive data between the socket-based client-server application. The Thread class will be used to create a multithreaded server application, and various Swing components will be used to create user interfaces for both the client and server applications. The design techniques of inheritance and composition will be employed as well. In short, this chapter brings together a lot of the concepts discussed up to this point in the book.




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net