Chapter 11

Remote Client

 

 

Universal TeacherIn all the previous chapters, the server class extended the UnicastRemoteObject and implemented a RemoteInterface. The server was responsible for:

creating one or more instances of the remote object, and
exporting those remote objects.

This chapter shows an example in which the client also exports remote objects.

Both the server and client act as client and server.

The source code needed for this example is stored in the examples\Remoteclient directory. The "Remoteclient" directory contains the following files:

  • ServerInterface.java
  • RemoteServerImpl.java
  • ClientInterface.java
  • RemoteClientImpl.java
  • Compile.bat
  • Rmicompile.bat
  • RunServer.bat
  • RunClient.bat

Universal TeacherServer Architecture

The design of the server is simple. The server starts a registry service and registers itself with the registry. It exports a method to enable a client to get registered, and post messages to the server.

When a client registers itself, it passes a reference to itself. The server uses the client reference to pass messages to client. The client makes an initial contact with the server via a registry service, and passes a reference to itself by calling a remote method.

The server and client use a String object to pass messages. A thread object is created to send messages.

Note

This application does not allow multiple clients to get connected to the server, and pass messages to the server. In other words, only one client can interact with the server at a time.

 

 

RMI BOOK MAIN PAGE                Top

  
Copyright © 2001 www.universalteacher.com