1 #include "ace/Get_Opt.h"
2 #include "Client_Worker.h"
5 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
6 ACE_TCHAR
*another_ior
= 0;
13 parse_args (int argc
, ACE_TCHAR
*argv
[])
15 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:n:i:x"));
18 while ((c
= get_opts ()) != -1)
22 ior
= get_opts
.opt_arg ();
26 nthreads
= ACE_OS::atoi (get_opts
.opt_arg ());
30 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
39 ACE_ERROR_RETURN ((LM_ERROR
,
48 // Indicates successful parsing of the command line
53 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
59 CORBA::ORB_init (argc
, argv
);
61 if (parse_args (argc
, argv
) != 0)
64 int len
= ACE_OS::strlen(ior
) + 1;
65 another_ior
= new ACE_TCHAR
[len
+ 1];
66 ACE_OS::strcpy(another_ior
, ior
);
67 another_ior
[len
-1] = '1';
68 another_ior
[len
] = '\0';
70 // Get Object Reference using IOR file
71 CORBA::Object_var object
=
72 orb
->string_to_object (ior
);
74 // Cast to Appropriate Type
75 Simple_Server_var server
=
76 Simple_Server::_narrow (object
.in ());
78 if (CORBA::is_nil (server
.in ()))
80 ACE_ERROR_RETURN ((LM_ERROR
,
81 "Object reference <%s> is nil\n", ior
),
87 orb
->string_to_object (another_ior
);
89 // Cast to Appropriate Type
90 Another_One_var another
=
91 Another_One::_narrow (object
.in ());
94 Client_Worker
client (server
.in (),
98 if (client
.activate (THR_NEW_LWP
| THR_JOINABLE
, nthreads
) != 0)
99 ACE_ERROR_RETURN ((LM_ERROR
,
100 " (%P|%t) Cannot Activate Client Threads\n"),
103 client
.thr_mgr ()->wait ();
105 ACE_DEBUG ((LM_DEBUG
,
106 "(%P|%t) threads finished\n"));
108 // Shut down the server if -x option given in command line
114 // Destroying the ORB..
118 catch (const CORBA::Exception
& ex
)
120 ex
._tao_print_exception ("Exception caught:");