1 #include "Echo_Client_i.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/Read_Buffer.h"
4 #include "ace/OS_NS_unistd.h"
5 #include "tao/Messaging/Messaging.h"
7 // This is the interface program that accesses the remote object
10 Echo_Client_i::Echo_Client_i () : payload_length_ (0)
16 Echo_Client_i::~Echo_Client_i ()
22 Echo_Client_i::parse_args (int argc
, ACE_TCHAR
*argv
[])
24 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("p:"));
27 while ((c
= get_opts ()) != -1)
31 this->payload_length_
= ACE_OS::atoi(get_opts
.opt_arg ()) * 1000000;
34 // Indicates successful parsing of the command line
40 Echo_Client_i::run (const char *name
,
44 // Initialize the client.
45 if (client_
.init (name
, argc
, argv
) == -1)
48 if (this->parse_args (argc
, argv
) == -1)
53 CORBA::PolicyList policyList
;
55 CORBA::Any objectTimeout
;
56 TimeBase::TimeT to
= 50000;
57 to
*= 365 * 24 * 3600;
60 policyList
[0] = client_
.orb()->create_policy(
61 Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE
,
63 CORBA::Object_var object
=
64 client_
->_set_policy_overrides(policyList
, CORBA::ADD_OVERRIDE
);
66 Echo_var
srv(Echo::_narrow(object
.in ()));
68 char* buf
= new char [this->payload_length_
+ 1];
69 ACE_OS::memset (buf
, 'a', this->payload_length_
);
70 buf
[this->payload_length_
] = '\0';
71 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Sending len: %d \n"), ACE_OS::strlen (buf
)));
73 CORBA::String_var s
= srv
->echo_string (buf
);
76 ACE_TEXT ("\nString echoed by client has len %d\n"),
77 ACE_OS::strlen(s
.in ())));
81 if (client_
.do_shutdown () == 1)
84 catch (const CORBA::Exception
& ex
)
86 ex
._tao_print_exception ("\n Exception in RMI");