2 //=============================================================================
6 * This is the client for the UDP performance test.
8 * @author Michael Kircher <Michael.Kircher@mchp.siemens.de>
10 //=============================================================================
13 #include "ace/Get_Opt.h"
19 #include "UDP_PerformanceClient.h"
21 // The following include file forces DIOP to be linked into the
22 // executable and initialized for static builds.
23 #include "tao/Strategies/advanced_resource.h"
26 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
27 ACE_UINT32 burst_messages
= 1000;
29 unsigned char performance_test
= 0;
32 parse_args (int argc
, ACE_TCHAR
*argv
[])
34 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:t:"));
37 while ((c
= get_opts ()) != -1)
41 ior
= get_opts
.opt_arg ();
44 burst_messages
= ACE_OS::atoi (get_opts
.opt_arg ());
48 ACE_ERROR_RETURN ((LM_ERROR
,
51 "-t <burst_messages> "
56 // Indicates successful parsing of the command line
61 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
66 CORBA::ORB_init (argc
, argv
, "PerformanceClient");
68 if (parse_args (argc
, argv
) != 0)
71 CORBA::Object_var object
=
72 orb
->string_to_object (ior
);
75 UDP::_narrow (object
.in ());
77 if (CORBA::is_nil (udp_var
.in ()))
79 ACE_ERROR_RETURN ((LM_ERROR
,
80 "Object reference <%s> is nil.\n",
85 // Activate POA to handle the call back.
86 CORBA::Object_var poa_object
=
87 orb
->resolve_initial_references("RootPOA");
89 if (CORBA::is_nil (poa_object
.in ()))
90 ACE_ERROR_RETURN ((LM_ERROR
,
91 " (%P|%t) Unable to initialize the POA.\n"),
94 PortableServer::POA_var root_poa
=
95 PortableServer::POA::_narrow (poa_object
.in ());
97 PortableServer::POAManager_var poa_manager
=
98 root_poa
->the_POAManager ();
100 poa_manager
->activate ();
102 // Instantiate reply handler
105 // let it remember our ORB
106 udp_i
.orb (orb
.in ());
108 UDP_var udpHandler_var
=
111 // Instantiate client
112 ACE_Task_Base
* client
= new UDP_PerformanceClient (orb
.in (),
117 // let the client run in a separate thread
120 // ORB loop, will be shut down by our client thread
121 orb
->run (); // Fetch responses
123 ACE_DEBUG ((LM_DEBUG
, "ORB finished\n"));
127 root_poa
->destroy (true, // ethernalize objects
128 false); // wait for completion
132 // it is save to delete the client, because the client was actually
133 // the one calling orb->shutdown () triggering the end of the ORB
137 catch (const CORBA::Exception
& ex
)
139 ex
._tao_print_exception ("Caught exception:");