2 #include "ace/Get_Opt.h"
3 #include "tao/Messaging/Messaging.h"
5 const ACE_TCHAR
*ior
= ACE_TEXT ("file://test.ior");
6 const ACE_TCHAR
*loop_forever_ior
= ACE_TEXT ("file://forward_forever.ior");
7 bool shutdown_only
= false;
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:l:s"));
16 while ((c
= get_opts ()) != -1)
20 ior
= get_opts
.opt_arg ();
23 loop_forever_ior
= get_opts
.opt_arg ();
30 ACE_ERROR_RETURN ((LM_ERROR
,
37 // Indicates successful parsing of the command line
42 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
46 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - ORB_init()\n"));
47 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
49 if (parse_args (argc
, argv
) != 0)
52 CORBA::Object_var tmp
;
53 Test::Hello_var hello
;
57 tmp
= orb
->string_to_object (loop_forever_ior
);
59 if (CORBA::is_nil (tmp
.in ()))
61 ACE_ERROR_RETURN ((LM_DEBUG
,
62 "ERROR: Nil object from string_to_object of <%s>\n",
67 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - create timeout policy\n"));
68 // Three second relative roundtrip timeout.
69 TimeBase::TimeT timeout_period
= 30000000u;
71 CORBA::Any timeout_as_any
;
72 timeout_as_any
<<= timeout_period
;
74 CORBA::PolicyList
policy_list (1);
75 policy_list
.length (1);
77 orb
->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE
,
79 tmp
= tmp
->_set_policy_overrides (policy_list
,
82 for (CORBA::ULong i
= 0;
83 i
< policy_list
.length ();
86 policy_list
[i
]->destroy ();
91 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - loop_forever narrow\n"));
93 // This should LOCATION_FORWARD loop until the timeout
94 hello
= Test::Hello::_narrow(tmp
.in ());
96 if (CORBA::is_nil (hello
.in ()))
98 ACE_ERROR_RETURN ((LM_DEBUG
,
99 "ERROR: Nil hello from <%s>\n",
104 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - loop_forever call\n"));
105 CORBA::String_var the_string
= hello
->get_string ();
107 ACE_ERROR_RETURN ((LM_ERROR
,
108 "ERROR - We have managed to invoke a server method. \n"),
111 catch (const CORBA::TIMEOUT
&)
114 ACE_DEBUG ((LM_DEBUG
, "Test OK - RELATIVE_RT_TIMEOUT ends location forward loop.\n"));
118 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - shutdown server\n"));
119 tmp
= orb
->string_to_object (ior
);
121 hello
= Test::Hello::_narrow(tmp
.in ());
123 if (CORBA::is_nil (hello
.in ()))
125 ACE_ERROR_RETURN ((LM_DEBUG
,
126 "ERROR: Nil hello from <%s>\n",
133 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - End\n"));
136 catch (const CORBA::Exception
& ex
)
138 ex
._tao_print_exception ("ERROR: Exception caught:");
142 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - Test SUCCESSFULL!\n"));