summaryrefslogtreecommitdiff
path: root/TAO/examples/Simple/time/Time_Client_i.cpp
blob: 87feb97e0999896733d14b26badc48b1f14b9e82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "Time_Client_i.h"
#include "ace/OS_NS_time.h"

// This is the interface program that accesses the remote object

// Constructor.
Time_Client_i::Time_Client_i ()
{
  //no-op
}

//Destructor.
Time_Client_i::~Time_Client_i ()
{
  //no-op
}

int
Time_Client_i::run (const char *name,
                    int argc,
                    ACE_TCHAR *argv[])
{
  // Initialize the client.
  if (client_.init (name, argc, argv) == -1)
    return -1;

  try
    {
      // 64-bit OS's require pointers to be aligned on an
      // 8 byte boundary.
      CORBA::Long padding = 0;
      time_t timedate;

      ACE_UNUSED_ARG (padding);

      //Make the RMI.
      timedate = static_cast <time_t> (client_->current_time ());

      // Print out value
      ACE_TCHAR ascii_timedate[64] = ACE_TEXT ("");

      ACE_OS::ctime_r (&timedate, ascii_timedate, 64);

      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("string time is %s\n"),
                  ascii_timedate));

      if (client_.do_shutdown () == 1)
        client_->shutdown ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("\tException");
      return -1;
    }

  return 0;
}