Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Big_Reply / client.cpp
blob2889ffc3928dc6392609c03add9f7e84a1f3af2b
1 #include "Client_Task.h"
2 #include "ace/Get_Opt.h"
5 const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
6 bool server_shutdown = false;
8 int
9 parse_args (int argc, ACE_TCHAR *argv[])
11 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:x"));
12 int c;
14 while ((c = get_opts ()) != -1)
15 switch (c)
17 case 'k':
18 ior = get_opts.opt_arg ();
19 break;
20 case 'x':
21 server_shutdown = true;
22 break;
23 case '?':
24 default:
25 ACE_ERROR_RETURN ((LM_ERROR,
26 "usage: %s "
27 "-k <ior>"
28 "-x shutdown"
29 "\n",
30 argv [0]),
31 -1);
33 // Indicates successful parsing of the command line
34 return 0;
37 int
38 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
40 try
42 CORBA::ORB_var orb =
43 CORBA::ORB_init (argc, argv);
45 if (parse_args (argc, argv) != 0)
46 return 1;
48 CORBA::Object_var tmp =
49 orb->string_to_object (ior);
51 Test::Big_Reply_var reply_gen =
52 Test::Big_Reply::_narrow (tmp.in ());
54 if (CORBA::is_nil (reply_gen.in ()))
56 ACE_ERROR_RETURN ((LM_DEBUG,
57 "Nil coordinator reference <%s>\n",
58 ior),
59 1);
62 Client_Task client_task (reply_gen.in (),
63 10,
64 ACE_Thread_Manager::instance ());
66 if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1) == -1)
68 ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
70 ACE_Thread_Manager::instance ()->wait ();
72 ACE_DEBUG ((LM_DEBUG, "Got all the replies...\n"));
74 if (server_shutdown)
76 // Request the server to shutdown
77 reply_gen->shutdown ();
80 orb->destroy ();
82 catch (const CORBA::Exception& ex)
84 ex._tao_print_exception ("Exception caught:");
85 return 1;
88 return 0;