Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Muxing / client.cpp
blob9f69fba62ea0d09a778da7f7249ece9163078c82
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
68 Client_Task client_task (receiver.in (),
69 #if defined (ACE_OPENVMS)
70 750, /* test takes much longer on OpenVMS */
71 #else
72 1000,
73 #endif
74 32768,
75 ACE_Thread_Manager::instance ());
77 if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1) == -1)
79 ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
81 ACE_Thread_Manager::instance ()->wait ();
83 CORBA::Long count = receiver->get_event_count ();
85 ACE_DEBUG ((LM_DEBUG, "(%P) - Receiver got %d messages\n",
86 count));
88 orb->destroy ();
90 catch (const CORBA::Exception& ex)
92 ex._tao_print_exception ("Exception caught:");
93 return 1;
96 return 0;