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
[])
72 // Initialize the ORB.
74 CORBA::ORB_init (argc
, argv
);
76 // Initialize options based on command-line arguments.
77 int parse_args_result
= parse_args (argc
, argv
);
78 if (parse_args_result
!= 0)
79 return parse_args_result
;
81 // Get an object reference from the argument string.
82 CORBA::Object_var object
=
83 orb
->string_to_object (IOR
);
85 // Try to narrow the object reference to a <test> reference.
86 test_var test_object
= test::_narrow (object
.in ());
88 test::data
the_data0 (data_bytes
);
89 the_data0
.length (data_bytes
);
92 test::data
the_data1 (data_bytes
);
93 the_data1
.length (data_bytes
);
96 test::data
the_data2 (data_bytes
);
97 the_data2
.length (data_bytes
);
99 for (CORBA::ULong i
= 1; i
<= iterations
; ++i
)
101 ACE_DEBUG ((LM_DEBUG
,
102 "client: Iteration %d @ %T\n",
105 // Invoke the oneway method.
106 test_object
->method (i
,
109 // Invoke the oneway method.
110 test_object
->method (i
,
113 // Invoke the oneway method.
114 test_object
->method (i
,
121 ACE_DEBUG ((LM_DEBUG
,
122 "(%P|%t) Sending a shutdown call..\n"));
123 test_object
->shutdown ();
126 // Destroy the ORB. On some platforms, e.g., Win32, the socket
127 // library is closed at the end of main(). This means that any
128 // socket calls made after main() fail. Hence if we wait for
129 // static destructors to flush the queues, it will be too late.
130 // Therefore, we use explicit destruction here and flush the
131 // queues before main() ends.
134 catch (const CORBA::Exception
& ex
)
136 ex
._tao_print_exception ("Exception caught:");