1 #include "McastHello.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
4 #include "orbsvcs/PortableGroup/MIOP.h"
5 #include "orbsvcs/PortableGroup/GOA.h"
7 static const ACE_TCHAR
*ior_output_file
= ACE_TEXT("test.ior");
9 // Use a multicast address in the administrative "site local" range, 239.255.0.0 to
10 // 239.255.255.255. The range 224.255.0.0 to 238.255.255.255 should also be valid
12 //static const char *group_ior = "corbaloc:miop:1.0@1.0-TestDomain-1/239.255.0.1:16000";
13 static const ACE_TCHAR
*group_ior
= ACE_TEXT("corbaloc:miop:1.0@1.0-TestDomain-1/224.1.239.2:1234");
16 parse_args (int argc
, ACE_TCHAR
*argv
[])
18 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
21 while ((c
= get_opts ()) != -1)
25 ior_output_file
= get_opts
.opt_arg ();
29 group_ior
= get_opts
.opt_arg ();
34 ACE_ERROR_RETURN ((LM_ERROR
,
37 "-g <group ior corbaloc>"
42 // Indicates successful parsing of the command line
47 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
52 CORBA::ORB_init (argc
, argv
);
54 CORBA::Object_var poa_object
=
55 orb
->resolve_initial_references("RootPOA");
57 PortableGroup::GOA_var root_poa
=
58 PortableGroup::GOA::_narrow (poa_object
.in ());
60 if (CORBA::is_nil (root_poa
.in ()))
61 ACE_ERROR_RETURN ((LM_ERROR
,
62 " (%P|%t) Panic: nil RootPOA\n"),
65 PortableServer::POAManager_var poa_manager
=
66 root_poa
->the_POAManager ();
68 if (parse_args (argc
, argv
) != 0)
71 CORBA::Object_var group1
=
72 orb
->string_to_object (group_ior
);
74 // Output the Group IOR to the <ior_output_file>
75 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
77 ACE_ERROR_RETURN ((LM_ERROR
,
78 "Cannot open output file for writing IOR: %s",
81 ACE_OS::fprintf (output_file
, "%s", ACE_TEXT_ALWAYS_CHAR (group_ior
));
82 ACE_OS::fclose (output_file
);
84 PortableServer::ObjectId_var id
=
85 root_poa
->create_id_for_reference (group1
.in ());
87 // Create and activate an instance of our servant.
88 McastHello
server_impl (orb
.in (), 0);
90 root_poa
->activate_object_with_id (id
.in (),
94 poa_manager
->activate ();
98 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
100 root_poa
->destroy (true, true);
104 // Validate that our servants got the right requests.
105 if (server_impl
.get_status () == 0)
106 ACE_ERROR_RETURN ((LM_ERROR
,
107 "Multicast Servant did not receive expected requests!\n"),
110 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - Success!\n"));
112 catch (const CORBA::Exception
& ex
)
114 ex
._tao_print_exception ("Exception caught:");