1 #include "MessengerC.h"
2 #include "orbsvcs/CosNamingC.h"
3 #include "ace/OS_NS_unistd.h"
4 #include "ace/Get_Opt.h"
7 const ACE_TCHAR
*ior_file
= ACE_TEXT ("file://Messenger.ior");
10 parse_args (int argc
, ACE_TCHAR
*argv
[])
12 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
15 while ((c
= get_opts ()) != -1)
19 ior_file
= get_opts
.opt_arg ();
24 ACE_ERROR_RETURN ((LM_ERROR
,
31 // Indicates successful parsing of the command line
36 ACE_TMAIN(int argc
, ACE_TCHAR
* argv
[])
41 CORBA::ORB_var orb
= CORBA::ORB_init(argc
, argv
);
43 if (parse_args (argc
, argv
) != 0)
47 CORBA::Object_var obj
= orb
->string_to_object(ACE_TEXT_ALWAYS_CHAR(ior_file
));
48 if (CORBA::is_nil(obj
.in())) {
49 std::cerr
<< "Nil Messenger reference" << std::endl
;
54 Messenger_var messenger
= Messenger::_narrow( obj
.in() );
55 if (CORBA::is_nil(messenger
.in())) {
56 std::cerr
<< "Argument is not a Messenger reference" << std::endl
;
60 CORBA::String_var message
= CORBA::string_dup(
61 "Where can I get TAO?");
62 for (int i
=0; i
<120; i
++) {
64 messenger
->send_message ("person@company.com",
65 "OCI's Distribution of TAO",
69 catch(const CORBA::Exception
& ex
)
71 std::cerr
<< "Caught exception: " << ex
<< std::endl
;