Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Connection_Purging / client.cpp
blob5e9d5a9f647e8caada25a425dcbd8856bf41a8e5
1 #include "testC.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_unistd.h"
4 #include "tao/Strategies/advanced_resource.h"
6 const ACE_TCHAR *ior = ACE_TEXT("server.ior");
8 int
9 parse_args (int argc, ACE_TCHAR *argv[])
11 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
12 int c;
14 while ((c = get_opts ()) != -1)
15 switch (c)
17 case 'k':
18 ior = get_opts.opt_arg ();
19 break;
21 case '?':
22 default:
23 ACE_ERROR_RETURN ((LM_ERROR,
24 "usage: %s "
25 "-k <ior> "
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
39 CORBA::ORB_var orb =
40 CORBA::ORB_init (argc, argv);
42 if (parse_args (argc, argv) != 0)
43 return 1;
45 int done = 0;
46 test_var holder;
47 for(int i = 0; !done; i++)
49 ACE_TCHAR number[64];
50 ACE_TString iorfile(ior);
52 ACE_OS::sprintf (number, ACE_TEXT(".%d"), i);
53 iorfile += number;
55 if (ACE_OS::access(iorfile.c_str (), R_OK) == 0)
57 iorfile = ACE_TEXT("file://") + iorfile;
58 CORBA::Object_var tmp =
59 orb->string_to_object(iorfile.c_str ());
61 test_var test =
62 test::_narrow(tmp.in ());
64 if (CORBA::is_nil (test.in ()))
66 ACE_ERROR_RETURN ((LM_DEBUG,
67 "Nil test reference <%s>\n",
68 ior),
69 1);
72 test->send_stuff ("Some stuff to send");
74 // Test for LFU strategy. The transport to any other
75 // server should be removed before the first one.
76 if (i == 0)
78 test->send_stuff ("Some stuff to send");
80 holder = test;
82 else if (i == 5) // let a few go by before we reuse holder
83 { // This will test the LRU strategy
84 // This transport should be the 6th one
85 // removed.
86 if (!CORBA::is_nil(holder.in ()))
88 holder->send_stuff ("Some stuff to send");
92 else
94 done = 1;
98 orb->shutdown (true);
100 orb->destroy ();
102 catch (const CORBA::Exception& ex)
104 ex._tao_print_exception ("Exception caught:");
105 return 1;
108 return 0;