Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Bug_3683_Regression / Echo_Client_i.cpp
blobe62b854ae011d342a5bcd9e5907afd5ae99fbdb6
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
9 // Constructor.
10 Echo_Client_i::Echo_Client_i () : payload_length_ (0)
12 //no-op
15 //Destructor.
16 Echo_Client_i::~Echo_Client_i ()
18 //no-op
21 int
22 Echo_Client_i::parse_args (int argc, ACE_TCHAR *argv[])
24 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("p:"));
25 int c;
27 while ((c = get_opts ()) != -1)
28 switch (c)
30 case 'p':
31 this->payload_length_ = ACE_OS::atoi(get_opts.opt_arg ()) * 1000000;
32 break;
34 // Indicates successful parsing of the command line
35 return 0;
39 int
40 Echo_Client_i::run (const char *name,
41 int argc,
42 ACE_TCHAR *argv[])
44 // Initialize the client.
45 if (client_.init (name, argc, argv) == -1)
46 return -1;
48 if (this->parse_args (argc, argv) == -1)
49 return -1;
51 try
53 CORBA::PolicyList policyList;
54 policyList.length(1);
55 CORBA::Any objectTimeout;
56 TimeBase::TimeT to = 50000;
57 to *= 365 * 24 * 3600;
58 to *= 100;
59 objectTimeout <<= to;
60 policyList[0] = client_.orb()->create_policy(
61 Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
62 objectTimeout);
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);
75 ACE_DEBUG ((LM_DEBUG,
76 ACE_TEXT ("\nString echoed by client has len %d\n"),
77 ACE_OS::strlen(s.in ())));
79 delete [] buf;
81 if (client_.do_shutdown () == 1)
82 client_->shutdown ();
84 catch (const CORBA::Exception& ex)
86 ex._tao_print_exception ("\n Exception in RMI");
87 return -1;
90 return 0;