2 #include "ace/Get_Opt.h"
3 #include "ace/Task_T.h"
4 #include "ace/OS_NS_unistd.h"
5 #include "tao/TimeBaseC.h"
6 #include "tao/Messaging/Messaging.h"
8 const ACE_TCHAR
*ior
= ACE_TEXT ("file://test.ior");
9 bool shutdown_server
= false;
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:x"));
17 while ((c
= get_opts ()) != -1)
21 ior
= get_opts
.opt_arg ();
24 shutdown_server
= true;
29 ACE_ERROR_RETURN ((LM_ERROR
,
36 // Indicates successful parsing of the command line
40 class Client
: public ACE_Task_Base
43 Client (CORBA::ORB_ptr server
);
52 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
56 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
58 if (parse_args (argc
, argv
) != 0)
61 // Set round-trip timeout
62 const int timeout_secs
= 5;
64 CORBA::Object_var obj
= orb
->resolve_initial_references ("ORBPolicyManager");
65 CORBA::PolicyManager_var policy_manager
=
66 CORBA::PolicyManager::_narrow (obj
.in());
68 CORBA::PolicyList policy_list
;
69 policy_list
.length(0);
70 policy_manager
->set_policy_overrides(policy_list
, CORBA::SET_OVERRIDE
);
72 TimeBase::TimeT timeout
= timeout_secs
* 10000000;
73 CORBA::Any orb_timeout
;
74 orb_timeout
<<= timeout
;
75 policy_list
.length(1);
76 policy_list
[0] = orb
->create_policy(
77 Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE
, orb_timeout
);
79 policy_manager
->set_policy_overrides(policy_list
, CORBA::SET_OVERRIDE
);
81 CORBA::Object_var tmp
= orb
->string_to_object(ior
);
83 Test::Hello_var hello
= Test::Hello::_narrow(tmp
.in ());
85 if (CORBA::is_nil (hello
.in ()))
87 ACE_ERROR_RETURN ((LM_DEBUG
,
88 "Nil Test::Hello reference <%s>\n",
96 "(%P|%t) Calling shutdown on server\n"));
101 Client
client (orb
.in ());
102 if (client
.activate (THR_NEW_LWP
| THR_JOINABLE
, 1) != 0)
103 ACE_ERROR_RETURN ((LM_ERROR
,
104 "Cannot activate client threads\n"),
107 CORBA::String_var the_string
;
110 the_string
= hello
->get_string ();
112 catch (const CORBA::TIMEOUT
&)
114 ACE_DEBUG ((LM_DEBUG
,
115 "(%P|%t) Error: got timeout\n"));
117 catch (const CORBA::COMM_FAILURE
&)
119 ACE_DEBUG ((LM_DEBUG
,
120 "(%P|%t) Ok: got comm exception\n"));
123 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) - string returned <%C>\n",
126 client
.thr_mgr ()->wait ();
131 catch (const CORBA::Exception
& ex
)
133 ex
._tao_print_exception ("Exception caught:");
140 Client::Client (CORBA::ORB_ptr orb
)
141 : orb_ (CORBA::ORB::_duplicate (orb
))
151 ACE_DEBUG ((LM_DEBUG
,
152 "(%P|%t) Shutting down ORB\n"));
153 orb_
->shutdown (true);
155 catch (const CORBA::Exception
&)