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)
23 ior
= get_opts
.opt_arg ();
27 nthreads
= ACE_OS::atoi (get_opts
.opt_arg ());
31 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
40 ACE_ERROR_RETURN ((LM_ERROR
,
49 // Indicates successful parsing of the command line
54 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
60 CORBA::ORB_init (argc
, argv
);
62 if (parse_args (argc
, argv
) != 0)
65 int len
= ACE_OS::strlen(ior
) + 1;
66 another_ior
= new ACE_TCHAR
[len
+ 1];
67 ACE_OS::strcpy(another_ior
, ior
);
68 another_ior
[len
-1] = '1';
69 another_ior
[len
] = '\0';
71 // Get Object Reference using IOR file
72 CORBA::Object_var object
=
73 orb
->string_to_object (ior
);
75 // Cast to Appropriate Type
76 Simple_Server_var server
=
77 Simple_Server::_narrow (object
.in ());
79 if (CORBA::is_nil (server
.in ()))
81 ACE_ERROR_RETURN ((LM_ERROR
,
82 "Object reference <%s> is nil\n", ior
),
88 orb
->string_to_object (another_ior
);
90 // Cast to Appropriate Type
91 Another_One_var another
=
92 Another_One::_narrow (object
.in ());
95 Client_Worker
client (server
.in (),
99 if (client
.activate (THR_NEW_LWP
| THR_JOINABLE
, nthreads
) != 0)
100 ACE_ERROR_RETURN ((LM_ERROR
,
101 " (%P|%t) Cannot Activate Client Threads\n"),
104 client
.thr_mgr ()->wait ();
106 ACE_DEBUG ((LM_DEBUG
,
107 "(%P|%t) threads finished\n"));
109 // Shut down the server if -x option given in command line
115 // Destroying the ORB..
119 catch (const CORBA::Exception
& ex
)
121 ex
._tao_print_exception ("Exception caught:");