blob: b033db76d82fcf9c9906e1b3b18519a2d421dafb (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// $Id$
//
// ============================================================================
//
// = LIBRARY
// orbsvcs/examples/PSS
//
// = FILENAME
// client.cpp
//
// = DESCRIPTION
// This implements a simple CORBA client for the
// Server.idl
//
// = AUTHOR
// Priyanka Gontla <pgontla@ece.uci.edu>
//
//
// ============================================================================
#include "ServerC.h"
#include "Simple_Naming_i.h"
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
// Get a reference to the RootPOA
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
// Narrow down to the correct reference
PortableServer::POA_var poa =
PortableServer::POA::_narrow (poa_object.in ());
// Set a POA Manager
PortableServer::POAManager_var poa_manager =
poa->the_POAManager ();
// Activate the POA Manager
poa_manager->activate ();
// Get a reference to Simple_Naming
CORBA::Object_var simple_naming_object =
orb->resolve_initial_references ("Simple_Naming");
// Narrow down the reference
Simple_Naming::Naming_Context_var simple_naming =
Simple_Naming::Naming_Context::_narrow (simple_naming_object.in());
Simple_Naming::Name name = CORBA::string_dup ("Server");
CORBA::String_var ior_string =
simple_naming->find (name);
// Connect to the server
CORBA::Object_var tmp =
orb->string_to_object(ior_string.in ());
Simple_Server::Server_var server =
Simple_Server::Server::_narrow (tmp.in ());
CORBA::String_var status =
server->get_status ();
if (ACE_OS::strcmp (status.in (), "active") != 0)
{
ACE_DEBUG ((LM_ERROR,
"ERROR: The server didnt return the active status\n"));
return -1;
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Client raised an exception:\n");
}
return 0;
}
|