// 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 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.
To implement
// 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.
};
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.
if you use the
iiop:1.0//danzon.cs.wustl.edu:10015/P35ad159600081a38/child_poa/server
-ORBobjrefstyle url IOR format or
If you use the
IOR:000000000000001649444c3a43756269745...
-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.
Last modified 16:40:20 CST 17 March 1999