Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / Muxing / client.cpp
blobbe952d708d6812d93dc3835b382e230be213cce7
1 #include "Client_Task.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
5 bool shutdown_srv = false;
7 int
8 parse_args (int argc, ACE_TCHAR *argv[])
10 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:x"));
11 int c;
13 while ((c = get_opts ()) != -1)
14 switch (c)
16 case 'k':
17 ior = get_opts.opt_arg ();
18 break;
19 case 'x':
20 shutdown_srv = true;
21 break;
22 case '?':
23 default:
24 ACE_ERROR_RETURN ((LM_ERROR,
25 "usage: %s "
26 "-k <ior> "
27 "[-x]"
28 "\n",
29 argv [0]),
30 -1);
32 // Indicates successful parsing of the command line
33 return 0;
36 int
37 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
39 try
41 CORBA::ORB_var orb =
42 CORBA::ORB_init (argc, argv);
44 if (parse_args (argc, argv) != 0)
45 return 1;
47 CORBA::Object_var tmp =
48 orb->string_to_object(ior);
50 Test::Receiver_var receiver =
51 Test::Receiver::_narrow(tmp.in ());
53 if (CORBA::is_nil (receiver.in ()))
55 ACE_ERROR_RETURN ((LM_DEBUG,
56 "Nil coordinator reference <%s>\n",
57 ior),
58 1);
61 if (shutdown_srv)
63 receiver->shutdown ();
65 else
67 Client_Task client_task (receiver.in (),
68 1000,
69 32768,
70 ACE_Thread_Manager::instance ());
72 if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1) == -1)
74 ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
76 ACE_Thread_Manager::instance ()->wait ();
78 CORBA::Long count = receiver->get_event_count ();
80 ACE_DEBUG ((LM_DEBUG, "(%P) - Receiver got %d messages\n",
81 count));
83 orb->destroy ();
85 catch (const CORBA::Exception& ex)
87 ex._tao_print_exception ("Exception caught:");
88 return 1;
91 return 0;