CORBA Time/Date Assignment

In this assignment, you will implement a remote time and date service using CORBA. Applications use this service to determine the current time and date in a network. In this service, CORBA remote operations are used to request the current date and time from a particular machine.


Design and Implementation Issues

CORBA IDL Interface

The CORBA remote time/date service will be designed as a client/server pair using the following IDL specification:
// IDL schema definition for Time and Date interface.
interface Time_Date
{
  void bin_date (out long time_date);
  // Obtain the time and date in binary format.

  void str_date (out string time_date);
  // Obtain the time and date in string format.
};
The time and date can be returned as either a binary number or as a string. If the number is returned as a binary then you can converted it into a string and printed to the stdout of the user using the ctime(3c) C library function. If the number is returned as a string then you don't need to do any conversions. Note that by returning the time and date as a long you'll save on network bandwidth.

You will use a CORBA IDL compiler to translate this specification into client-side stubs and server-side skeletons. The client application (which you must write) will use the stubs as a proxy to access the time and date service implemented by the server. You must also write the implementation of the server, which provides the time and date service.

Client Functionality

For the purposes of the assignment, you can make the client-side driver program very simple. The client can read a command from its standard input and send it to the server. For example, you could the following commands to the client:
% ./client tango.cs.wustl.edu
> b
Binary time is 71478939
> s
String time is Sat Jan 1 0:00 1900
For hints on how to design the client, take a look at the Quoter example we discussed in class.

Server Functionality

On the server-side, you'll need to define a class that inherits from the skeleton generated by the IDL compiler. The C++ class for this should look something like the following:

// Implement the Time_Date interface.

class Time_Date_i : virtual public POA_Time_Date
{
public:
  virtual void bin_date (CORBA::Long_out time_date,
                         CORBA::Environment &ACE_TRY_ENV = 
                           CORBA::Environment::default_environment ());
  // Obtain the time and date in binary format.

  virtual void str_date (CORBA::String_out time_date,
                         CORBA::Environment &ACE_TRY_ENV = 
                           CORBA::Environment::default_environment ());
  // Obtain the time and date in string format.
};
To implement bin_date you'll need to use the ACE_OS::time() system call. To implement str_date you'll need to use the ACE_OS::ctime() library function to convert the time on the server into an ASCII string representation of the time. I recommend that you check the UNIX manual pages for more details on using these functions.

In addition, you'll need to implement a main function that defines an instance of Time_Date_i, obtains and activates the RootPOA and then calls the ORB's run() method to start the event loop.

Invoking the Client and Server

Once the client and server components are written, compiled, and linked you'll need to get the client and server to work together. To make your life easy, the server should write its IOR to a file (later, we'll use more advanced techniques, such as a Naming Service). Thus, when your server is started, you should create a file that contains something like the following:

iiop:1.0//danzon.cs.wustl.edu:10015/P35ad159600081a38/child_poa/server
if you use the -ORBobjrefstyle url IOR format or
IOR:000000000000001649444c3a43756269745...
If you use the -ORBobjrefstyle ior IOR format.

When the client starts up, it will read the contents of the file into a string and use the string_to_object() method to convert the string into an object reference. This object reference will then be downcast via _narrow() to an object reference for the Time_Date interface. At this point, it can call the appropriate *_date method via the object reference to perform the remote invocations.


Learning and Using CORBA

We will be using the TAO CORBA Object Request Broker (ORB) implementation. Please see the online help for information on how to setup your TAO development environment on Washington University's computing system.


Concluding Remarks

This first CORBA assignment is simple. However, it will illustrate the basic skills required to become adept at distributed object computing with CORBA.

Last modified 16:40:20 CST 17 March 1999