Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / orbsvcs / tests / ImplRepo / kill_server / client.cpp
blob42d2f93c381015bdc9192be91da809488d419e47
1 #include "TestC.h"
2 #include <iostream>
3 #include "ace/Get_Opt.h"
4 #include "ace/OS_NS_unistd.h"
6 char pause_poa = ' ';
7 char resume_poa = ' ';
8 bool expect_transient = false;
10 int
11 parse_args (int argc, ACE_TCHAR *argv[])
13 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("e"));
14 int c;
16 while ((c = get_opts ()) != -1)
17 switch (c)
19 case 'e':
20 expect_transient = true;
21 break;
22 case '?':
23 default:
24 ACE_ERROR_RETURN ((LM_ERROR,
25 "usage: %s "
26 "\n",
27 argv [0]),
28 -1);
30 // Indicates successful parsing of the command line
31 return 0;
34 int
35 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
37 try {
38 // Initialize orb
39 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
41 if (parse_args (argc, argv) != 0)
42 return 1;
44 CORBA::Object_var obj = orb->resolve_initial_references("Test");
45 ACE_ASSERT (!CORBA::is_nil(obj.in()));
46 Test_var test = Test::_narrow( obj.in());
47 ACE_ASSERT (!CORBA::is_nil(test.in()));
49 CORBA::Short n = test->get_server_num ();
50 ACE_DEBUG ((LM_DEBUG,
51 "Client received reply from server %d\n",
52 n));
54 orb->destroy ();
56 if (expect_transient)
57 return -1;
58 return 0;
60 catch(const CORBA::TRANSIENT& ex) {
61 if (expect_transient)
62 return 0;
64 ex._tao_print_exception ("client:");
66 catch(const CORBA::Exception& ex) {
67 ex._tao_print_exception ("client:");
69 return -1;