Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / ImplRepo / Bug_2604_Regression / MessengerClient.cpp
blobf3b1557e85ebac0b65e5596c0b1ac0be5a4ef780
1 #include "MessengerC.h"
3 #include "ace/Log_Msg.h"
4 #include "ace/SString.h"
5 #include "ace/Get_Opt.h"
7 const ACE_TCHAR *ior = ACE_TEXT("file://messenger.ior");
9 int
10 parse_args (int argc, ACE_TCHAR *argv[])
12 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
13 int c;
15 while ((c = get_opts ()) != -1)
16 switch (c)
18 case 'k':
19 ior = get_opts.opt_arg ();
20 break;
22 case '?':
23 default:
24 ACE_ERROR_RETURN ((LM_ERROR,
25 "usage: %s "
26 "-k <ior> "
27 "\n",
28 argv [0]),
29 -1);
31 // Indicates successful parsing of the command line
32 return 0;
35 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
37 try
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->string_to_object (ior);
45 Messenger_var messenger = Messenger::_narrow (obj.in ());
46 if (CORBA::is_nil (messenger.in ()))
48 ACE_ERROR_RETURN ((LM_ERROR,
49 ACE_TEXT ("Unable to get a Messenger reference.\n")),
50 -1);
53 CORBA::String_var message = CORBA::string_dup("Hello!");
54 for (int i(0); i < 6; ++i)
56 try
58 messenger->send_message("TAO User", "TAO Test",
59 message.inout ());
60 ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Message was sent\n")
61 ACE_TEXT("Client got reply: %C\n"),
62 message.in()));
64 catch (const CORBA::Exception &ex)
66 ACE_CString str = ex._info ();
67 ACE_ERROR_RETURN ((LM_ERROR,
68 ACE_TEXT ("Client send_message () caught: %C\n"),
69 str.c_str ()), -1);
73 orb->destroy ();
75 return 0;
77 catch (const CORBA::Exception &ex)
79 ACE_CString str = ex._info ();
80 ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Client main() caught: %C\n"),
81 str.c_str ()), -1);
83 return -1;