2 #include "ace/Get_Opt.h"
3 #include "ace/Profile_Timer.h"
4 #include "tao/Messaging/Messaging.h"
5 #include "tao/AnyTypeCode/Any.h"
8 ACE_TEXT("corbaloc:iiop:192.3.47/10007/RandomObject");
10 ACE_Profile_Timer profile_timer
;
11 TimeBase::TimeT timeout_period
= 1000000;
14 parse_args (int argc
, ACE_TCHAR
*argv
[])
16 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
19 while ((c
= get_opts ()) != -1)
23 ior
= get_opts
.opt_arg ();
28 ACE_ERROR_RETURN ((LM_ERROR
,
35 // Indicates successful parsing of the command line
40 test_timeout (CORBA::Object_ptr object
)
43 profile_timer
.start ();
47 // First connection happens here..
48 Test::Hello_var hello
=
49 Test::Hello::_narrow(object
);
51 if (CORBA::is_nil (hello
.in ()))
53 ACE_ERROR_RETURN ((LM_DEBUG
,
54 "Nil Test::Hello reference <%s>\n",
59 CORBA::String_var the_string
=
62 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) - string returned <%C>\n",
67 catch (const CORBA::Exception
&)
70 profile_timer
.stop ();
72 // Get the elampsed time
73 ACE_Profile_Timer::ACE_Elapsed_Time el
;
74 profile_timer
.elapsed_time (el
);
76 // Give a 30% error margin for handling exceptions etc. It is a
77 // high margin, though!. But the timeout is too small and wider
79 // The elapsed time is in secs
80 if (el
.real_time
> 0.200)
82 ACE_ERROR_RETURN ((LM_ERROR
,
83 "(%P|%t) ERROR: Too long to timeout: %F\n",
89 "(%P|%t) Success, timeout: %F\n",
97 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
104 CORBA::ORB_init (argc
, argv
);
106 if (parse_args (argc
, argv
) != 0)
109 CORBA::Object_var tmp
=
110 orb
->string_to_object(ior
);
112 CORBA::Object_var object
=
113 orb
->resolve_initial_references ("PolicyCurrent");
115 CORBA::PolicyCurrent_var policy_current
=
116 CORBA::PolicyCurrent::_narrow (object
.in ());
118 CORBA::Any timeout_as_any
;
119 timeout_as_any
<<= timeout_period
;
121 CORBA::PolicyList
policy_list (1);
122 policy_list
.length (1);
124 orb
->create_policy (TAO::CONNECTION_TIMEOUT_POLICY_TYPE
,
127 policy_current
->set_policy_overrides (policy_list
,
128 CORBA::ADD_OVERRIDE
);
130 for (CORBA::ULong l
= 0;
131 l
!= policy_list
.length ();
134 policy_list
[l
]->destroy ();
137 retval
= test_timeout (tmp
.in ());
141 catch (const CORBA::Exception
& ex
)
143 ex
._tao_print_exception ("Exception caught:");