1 #include "ace/Get_Opt.h"
2 #include "ace/Read_Buffer.h"
5 // Name of file contains ior.
6 static const ACE_TCHAR
*IOR
= ACE_TEXT ("file://ior");
9 static u_long iterations
= 20;
11 // Default number of bytes to send as data.
12 static CORBA::ULong data_bytes
= 1000;
14 // Flag indicates whether to shutdown remote server or not upon client
16 static int shutdown_server
= 0;
19 parse_args (int argc
, ACE_TCHAR
**argv
)
21 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:i:d:x"));
24 while ((c
= get_opts ()) != -1)
28 IOR
= get_opts
.opt_arg ();
31 iterations
= ACE_OS::atoi (get_opts
.opt_arg ());
34 data_bytes
= ACE_OS::atoi (get_opts
.opt_arg ());
41 ACE_ERROR_RETURN ((LM_ERROR
,
53 ACE_ERROR_RETURN ((LM_ERROR
,
54 "Please specify the IOR for the servant\n"), -1);
57 ACE_ERROR_RETURN ((LM_ERROR
,
58 "Please specify a value of more than 10 bytes\n"),
61 // Indicates successful parsing of command line.
67 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
71 // Initialize the ORB.
73 CORBA::ORB_init (argc
, argv
);
75 // Initialize options based on command-line arguments.
76 int parse_args_result
= parse_args (argc
, argv
);
77 if (parse_args_result
!= 0)
78 return parse_args_result
;
80 // Get an object reference from the argument string.
81 CORBA::Object_var object
=
82 orb
->string_to_object (IOR
);
84 // Try to narrow the object reference to a <test> reference.
85 test_var test_object
= test::_narrow (object
.in ());
87 test::data
the_data0 (data_bytes
);
88 the_data0
.length (data_bytes
);
91 test::data
the_data1 (data_bytes
);
92 the_data1
.length (data_bytes
);
95 test::data
the_data2 (data_bytes
);
96 the_data2
.length (data_bytes
);
98 for (CORBA::ULong i
= 1; i
<= iterations
; ++i
)
100 ACE_DEBUG ((LM_DEBUG
,
101 "client: Iteration %d @ %T\n",
104 // Invoke the oneway method.
105 test_object
->method (i
,
108 // Invoke the oneway method.
109 test_object
->method (i
,
112 // Invoke the oneway method.
113 test_object
->method (i
,
120 ACE_DEBUG ((LM_DEBUG
,
121 "(%P|%t) Sending a shutdown call..\n"));
122 test_object
->shutdown ();
125 // Destroy the ORB. On some platforms, e.g., Win32, the socket
126 // library is closed at the end of main(). This means that any
127 // socket calls made after main() fail. Hence if we wait for
128 // static destructors to flush the queues, it will be too late.
129 // Therefore, we use explicit destruction here and flush the
130 // queues before main() ends.
133 catch (const CORBA::Exception
& ex
)
135 ex
._tao_print_exception ("Exception caught:");