Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / Connect_Strategy_Test / client.cpp
blobe89faed032e42d041b48ce40cbecb1192dbb6506
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
5 int do_shutdown = 0;
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:x:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'k':
16 ior = get_opts.opt_arg ();
17 break;
18 case 'x':
19 do_shutdown = ACE_OS::atoi (get_opts.opt_arg ());
20 break;
21 case '?':
22 default:
23 ACE_ERROR_RETURN ((LM_ERROR,
24 "usage: %s "
25 "-k <ior> "
26 "-x <do_shutdown>"
27 "\n",
28 argv [0]),
29 -1);
31 // Indicates successful parsing of the command line
32 return 0;
35 int
36 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
38 try
40 CORBA::ORB_var orb =
41 CORBA::ORB_init (argc, argv);
43 if (parse_args (argc, argv) != 0)
44 return 1;
46 CORBA::Object_var tmp =
47 orb->string_to_object(ior);
49 Test::Hello_var hello =
50 Test::Hello::_narrow(tmp.in ());
52 if (CORBA::is_nil (hello.in ()))
54 ACE_ERROR_RETURN ((LM_DEBUG,
55 "Nil Test::Hello reference <%s>\n",
56 ior),
57 1);
60 CORBA::String_var the_string =
61 hello->get_string ();
63 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
64 the_string.in ()));
66 if (do_shutdown)
68 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Going to shutdown server\n"));
69 hello->shutdown ();
72 orb->destroy ();
74 catch (const CORBA::Exception& ex)
76 ex._tao_print_exception ("Exception caught:");
77 return 1;
80 return 0;