Merge pull request #1815 from sonndinh/get_signal_info
[ACE_TAO.git] / TAO / interop-tests / CdrOutArg / tao / client.cpp
blob9ba9a67b3ccf2bfe2746cb2930a8693629718fbd
1 #include "ace/Get_Opt.h"
2 #include "testC.h"
3 #include "Client_ORBInitializer.h"
5 #include "tao/ORBInitializer_Registry.h"
7 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
9 int
10 parse_args (int argc, ACE_TCHAR *argv[])
12 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
13 int c;
15 while ((c = get_opts ()) != -1)
16 switch (c)
18 case 'k':
19 ior = get_opts.opt_arg ();
20 break;
21 default:
22 ACE_ERROR_RETURN ((LM_ERROR,
23 "usage: %s "
24 "-k <ior> "
25 "\n",
26 argv [0]),
27 -1);
29 return 0;
32 int
33 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
35 try
37 PortableInterceptor::ORBInitializer_ptr temp_initializer;
39 ACE_NEW_RETURN (temp_initializer,
40 Client_ORBInitializer,
41 -1); // No exceptions yet!
42 PortableInterceptor::ORBInitializer_var initializer =
43 temp_initializer;
45 PortableInterceptor::register_orb_initializer (initializer.in ());
47 CORBA::ORB_var orb =
48 CORBA::ORB_init (argc, argv);
50 if (parse_args (argc, argv) != 0)
51 return 1;
53 CORBA::Object_var object =
54 orb->string_to_object (ior);
56 Interop::CDR_Out_Arg_var server =
57 Interop::CDR_Out_Arg::_narrow (object.in ());
59 if (CORBA::is_nil (server.in ()))
61 ACE_ERROR_RETURN ((LM_ERROR,
62 "Object reference <%s> is nil.\n",
63 ior),
64 1);
67 CORBA::Long lv;
68 CORBA::Long_out arg (lv);
70 server->get_out (arg);
72 ACE_DEBUG ((LM_DEBUG, "first call passed\n"));
74 server->get_out (arg);
76 ACE_DEBUG ((LM_DEBUG, "second call passed\n"));
78 server->shutdown ();
80 orb->destroy ();
82 catch (const CORBA::Exception& ex)
84 ex._tao_print_exception ("Caught exception in client:");
85 return 1;
88 return 0;