3 #include "ace/Get_Opt.h"
6 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
9 bool server_shutdown
= false;
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:n:i:x"));
17 while ((c
= get_opts ()) != -1)
21 ior
= get_opts
.opt_arg ();
24 nthreads
= ACE_OS::atoi (get_opts
.opt_arg ());
27 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
30 server_shutdown
= true;
34 ACE_ERROR_RETURN ((LM_ERROR
,
43 // Indicates successful parsing of the command line
47 class Client
: public ACE_Task_Base
50 // Run the client thread
53 // Use the ACE_Task_Base class to run the client threads.
56 Client (Simple_Server_ptr server
, int niterations
);
60 // The thread entry point.
63 void validate_connection ();
64 // Validate the connection
67 Simple_Server_var server_
;
71 // The number of iterations on each client thread.
75 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
80 CORBA::ORB_init (argc
, argv
);
82 if (parse_args (argc
, argv
) != 0)
85 CORBA::Object_var object
=
86 orb
->string_to_object (ior
);
88 Simple_Server_var server
=
89 Simple_Server::_narrow (object
.in ());
91 if (CORBA::is_nil (server
.in ()))
93 ACE_ERROR_RETURN ((LM_ERROR
,
94 "Object reference <%s> is nil.\n",
99 Client
client (server
.in (), niterations
);
100 if (client
.activate (THR_NEW_LWP
| THR_JOINABLE
,
102 ACE_ERROR_RETURN ((LM_ERROR
,
103 "Cannot activate client threads\n"),
106 client
.thr_mgr ()->wait ();
108 ACE_DEBUG ((LM_DEBUG
, "threads finished\n"));
117 catch (const CORBA::Exception
& ex
)
119 ex
._tao_print_exception ("Caught exception:");
126 // ****************************************************************
128 Client::Client (Simple_Server_ptr server
,
130 : server_ (Simple_Server::_duplicate (server
)),
131 niterations_ (niterations
)
136 Client::validate_connection ()
138 // Ping the object 100 times, ignoring all exceptions.
139 // It would be better to use validate_connection() but the test must
140 // run on minimum CORBA builds too!
141 for (int j
= 0; j
!= 100; ++j
)
145 this->server_
->test_method ();
147 catch (const CORBA::Exception
&){}
156 this->validate_connection ();
158 for (int i
= 0; i
< this->niterations_
; ++i
)
160 this->server_
->test_method ();
162 if (TAO_debug_level
> 0 && i
% 100 == 0)
163 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) iteration = %d\n",
167 catch (const CORBA::Exception
& ex
)
169 ex
._tao_print_exception ("MT_Client: exception raised");