next up previous contents
Next: Compiling the Example Up: Writing Value-Added Servers with Previous: Implementing a Multi-Threaded

 

Implementing Clients

The client is simpler than the server. It is single threaded and calls server RPCs to do most work. It uses the the configuration options and error handling facilities of the SSM similar to the server use of them.

This section focuses on RPC issues.

 

Connection Management

The code for connection management is all in file client.C. The function connect_to_server connects to a server at a specific host and port. The original Sun RPC package has no direct support for this since it assumes you will use the port mapper facility. However, the Shore version of the package has a clnt_create_port function that could replace most of the code in connect_to_server.

The function disconnect_from_server demonstrates how to end a session with the server.

 

Client Side of RPCs

The client-side stubs for the RPCs are generated by rpcgen and placed in msg_clnt.c. Recall that we wrap the RPCs in C++ methods from the command_base_t abstract base class. From that class we derive command_client_t and implement the methods by calling the RPC stubs.

In client.C the function process_user_commands creates an command_client_t object, reads lines from standard input, and calls command_client_t::parse_command for each line. Method parse_command in turn calls the command_client_t wrapper methods.



Marvin Solomon
Fri Aug 2 13:40:14 CDT 1996