Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Bug_2112_Regression / client.cpp
blobe0ab3b5c44179016474cc4a636bc23fee545de0e
1 #include "ace/Log_Msg.h"
2 #include "tao/corba.h"
3 #include "tao/TimeBaseC.h"
4 #include "tao/Messaging/Messaging.h"
5 #include "orbsvcs/CosNamingC.h"
7 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
9 int retval = 0;
10 try
12 // Initialise ORB
13 CORBA::ORB_var Orb = CORBA::ORB_init(argc, argv);
15 // Set round-trip timeout
16 const int timeout_secs = 5;
18 CORBA::Object_var obj = Orb->resolve_initial_references ("ORBPolicyManager");
19 CORBA::PolicyManager_var policy_manager =
20 CORBA::PolicyManager::_narrow (obj.in());
22 CORBA::PolicyList policy_list;
23 policy_list.length(0);
24 policy_manager->set_policy_overrides(policy_list, CORBA::SET_OVERRIDE);
26 TimeBase::TimeT timeout = timeout_secs * 10000000;
27 CORBA::Any orb_timeout;
28 orb_timeout <<= timeout;
29 policy_list.length(1);
30 policy_list[0] = Orb->create_policy(
31 Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE, orb_timeout);
33 policy_manager->set_policy_overrides(policy_list, CORBA::SET_OVERRIDE);
35 // Now try to contact a server.
36 // Use a remote machine that is unreachable on the network.
37 const char * obj_ref = "corbaloc:iiop:1.0@10.123.123.123:4567/NameService";
39 obj = Orb->string_to_object(obj_ref);
41 CosNaming::NamingContext_var inc;
42 if(!CORBA::is_nil(obj.in ()))
44 ACE_DEBUG(( LM_INFO, "Attempting to contact %C\n", obj_ref ));
45 try
47 inc = CosNaming::NamingContext::_narrow(obj.in());
48 ACE_DEBUG(( LM_INFO, "OK\n" ));
50 catch(const CORBA::TRANSIENT &)
52 ACE_ERROR ((LM_ERROR, "Error, caught transient exception\n"));
53 retval = 1;
55 catch(const CORBA::TIMEOUT &)
57 ACE_DEBUG ((LM_DEBUG, "Caught correct timeout\n"));
61 catch (const ::CORBA::Exception &ex)
63 ex._tao_print_exception("ERROR : unexpected CORBA exception caugth :");
64 ++retval;
67 return retval;