summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordoccvs <doccvs@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-09-05 22:07:49 +0000
committerdoccvs <doccvs@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-09-05 22:07:49 +0000
commit37f7a861770ecd44d8fb293072ef404903cd3031 (patch)
tree5e4e65170621bd726ec31b7fd9967b933666e9b3
parentc6714427947aee3c47d1ad77574df031332b3904 (diff)
downloadATCD-37f7a861770ecd44d8fb293072ef404903cd3031.tar.gz
ChangeLogTag: Wed Sep 5 12:10:40 2001 Priyanka Gontla <gontla_p@ociweb.com>
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/MCast.idl19
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/MCast_Server_i.cpp14
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/MCast_Server_i.h18
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/Makefile61
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/README20
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/client.cpp33
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/ior_mcast_client_i.cpp75
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/ior_mcast_client_i.h35
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/server.cpp29
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/server_i.cpp184
-rw-r--r--TAO/orbsvcs/tests/IOR_MCast/server_i.h56
11 files changed, 544 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/IOR_MCast/MCast.idl b/TAO/orbsvcs/tests/IOR_MCast/MCast.idl
new file mode 100644
index 00000000000..bd46594a6f4
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/MCast.idl
@@ -0,0 +1,19 @@
+// $Id$
+
+module MCast
+{
+
+ interface Server
+ {
+ // = TITLE
+ //
+ // = DESCRIPTION
+ // Prints out the status.
+
+ boolean connect_server ();
+ // Return <true> if the server received the
+ // request from the client.
+
+ };
+
+};
diff --git a/TAO/orbsvcs/tests/IOR_MCast/MCast_Server_i.cpp b/TAO/orbsvcs/tests/IOR_MCast/MCast_Server_i.cpp
new file mode 100644
index 00000000000..dcee2c8aefe
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/MCast_Server_i.cpp
@@ -0,0 +1,14 @@
+// $Id$
+
+#include "MCast_Server_i.h"
+
+MCast_Server_i::MCast_Server_i (void)
+{
+ //Constructor.
+}
+
+CORBA::Boolean
+MCast_Server_i::connect_server (CORBA::Environment &)
+{
+ return 0;
+}
diff --git a/TAO/orbsvcs/tests/IOR_MCast/MCast_Server_i.h b/TAO/orbsvcs/tests/IOR_MCast/MCast_Server_i.h
new file mode 100644
index 00000000000..f57605ccde0
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/MCast_Server_i.h
@@ -0,0 +1,18 @@
+// $Id$
+
+#ifndef MCAST_SERVER_I_H
+#define MCAST_SERVER_I_H
+
+#include "MCastS.h"
+
+class MCast_Server_i : public POA_MCast::Server {
+public:
+ MCast_Server_i ();
+
+ // Simple method just to see that the client contacted the
+ // server. If does contact, a '0' is returned.
+ CORBA::Boolean connect_server (CORBA::Environment & =
+ TAO_default_environment ());
+};
+
+#endif /* MCAST_SERVER_I_H */
diff --git a/TAO/orbsvcs/tests/IOR_MCast/Makefile b/TAO/orbsvcs/tests/IOR_MCast/Makefile
new file mode 100644
index 00000000000..8b60e4c088c
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/Makefile
@@ -0,0 +1,61 @@
+#----------------------------------------------------------------------------
+#
+# $Id$
+#
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+ifndef TAO_ROOT
+ TAO_ROOT = $(ACE_ROOT)/TAO
+endif # ! TAO_ROOT
+
+IDL_FILES = MCast
+IDL_SRC = MCastC MCastS
+
+LDLIBS = -lTAO_CosNaming -lTAO_Svc_Utils -lTAO_IORTable -lTAO_PortableServer -lTAO -lACE
+
+CPPFLAGS += -I$(TAO_ROOT)/orbsvcs
+BIN = server client
+
+SRC = $(addsuffix .cpp, $(BIN) $(IDL_SRC) server_i ior_mcast_client_i MCast_Server_i)
+
+SERVER_OBJS = $(addsuffix .o, server server_i MCast_Server_i $(IDL_SRC))
+CLIENT_OBJS = $(addsuffix .o, client ior_mcast_client_i server_i MCast_Server_i $(IDL_SRC))
+
+TAO_IDLFLAGS += -Ge 1
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(ACE_ROOT)/include/makeinclude/macros.GNU
+include $(TAO_ROOT)/rules.tao.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
+include $(TAO_ROOT)/taoconfig.mk
+
+#----------------------------------------------------------------------------
+# Local targets
+#----------------------------------------------------------------------------
+
+.PRECIOUS: $(foreach ext, $(IDL_EXT), mcast$(ext))
+
+server: $(addprefix $(VDIR),$(SERVER_OBJS))
+ $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK)
+
+client: $(addprefix $(VDIR),$(CLIENT_OBJS))
+ $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK)
+
+realclean: clean
+ -$(RM) $(foreach ext, $(IDL_EXT), mcast$(ext))
+
+# DO NOT DELETE THIS LINE -- g++dep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+
+
+
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/TAO/orbsvcs/tests/IOR_MCast/README b/TAO/orbsvcs/tests/IOR_MCast/README
new file mode 100644
index 00000000000..c1ba4a88b3a
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/README
@@ -0,0 +1,20 @@
+// $Id$
+
+This is a simple test for testing the multicast ior parser with format
+mcast://multicast_address:port:nicaddress:ttl
+
+The Client requests for the IOR of a service that is multicasted.
+The Server helps get this ior with the use of the TAO_IOR_Multicast
+class in the libTAO_Svc_Utils library.
+
+It should test the nic address and ttl parts too of the mcast format.
+
+You can run the test as:
+
+% ./server -a 224.0.1.27:12345 -ORBEndpoint iiop://doc.ece.uci.edu:23456
+
+ The '-a' option is to give the multicast address to which the
+requests to the server should be directed to.
+
+% ./client -ORBInitRef MCASTServer=mcast://224.0.1.27:12345:eth0:2/MCASTServer
+
diff --git a/TAO/orbsvcs/tests/IOR_MCast/client.cpp b/TAO/orbsvcs/tests/IOR_MCast/client.cpp
new file mode 100644
index 00000000000..09bbb6960c3
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/client.cpp
@@ -0,0 +1,33 @@
+// $Id$
+
+#include "ior_mcast_client_i.h"
+
+int main (int argc, char *argv [])
+{
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+
+ ACE_TRY
+ {
+
+ ior_mcast_Client_i client;
+
+ int init_result;
+ init_result = client.init (argc, argv, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ return 0;
+ }
+ ACE_CATCH (CORBA::SystemException, ex)
+ {
+ //
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "client");
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
diff --git a/TAO/orbsvcs/tests/IOR_MCast/ior_mcast_client_i.cpp b/TAO/orbsvcs/tests/IOR_MCast/ior_mcast_client_i.cpp
new file mode 100644
index 00000000000..63f346939f5
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/ior_mcast_client_i.cpp
@@ -0,0 +1,75 @@
+// $Id$
+
+#include "ior_mcast_client_i.h"
+#include "ace/Get_Opt.h"
+#include "ace/Read_Buffer.h"
+
+ior_mcast_Client_i::ior_mcast_Client_i (void)
+{
+ // Constructor
+}
+
+ior_mcast_Client_i::~ior_mcast_Client_i (void)
+{
+}
+
+int
+ior_mcast_Client_i::init (int& argc,
+ char *argv[],
+ CORBA::Environment &ACE_TRY_ENV)
+{
+
+ ACE_TRY
+ {
+ // First initialize the ORB, that will remove some arguments...
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc,
+ argv,
+ "" /* the ORB name, it can be anything! */,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ CORBA::Object_var mcast_server_object =
+ orb->resolve_initial_references ("MCASTServer", ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (mcast_server_object.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot resolve MCast Server\n : client"),
+ -1);
+
+ MCast::Server_var mcast_srvr =
+ MCast::Server::_narrow (mcast_server_object.in (), ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (mcast_srvr.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot narrow MCast Service\n :client"),
+ -1);
+
+ // Invoke a request on the server
+ CORBA::Boolean ret_value =
+ mcast_srvr->connect_server (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ if (ret_value != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "The server has not been contacted. Error!!\n",
+ 0));
+ }
+ }
+ ACE_CATCH (CORBA::SystemException, ex)
+ {
+ ACE_PRINT_EXCEPTION (ex, "client");
+ return -1;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "client");
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
diff --git a/TAO/orbsvcs/tests/IOR_MCast/ior_mcast_client_i.h b/TAO/orbsvcs/tests/IOR_MCast/ior_mcast_client_i.h
new file mode 100644
index 00000000000..68e8ece6575
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/ior_mcast_client_i.h
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+// $Id$
+
+#if !defined (IOR_MCAST_CLIENT_I_H)
+#define IOR_MCAST_CLIENT_I_H
+
+#include "MCastC.h"
+
+class ior_mcast_Client_i
+{
+ // = TITLE
+ // ior_mcast_client_i.h
+ //
+ // = DESCRIPTION
+ // Helper class for the client which uses the mcast ior type to
+ // get reference to the server.
+
+ public:
+ // = COnstructor and destructor.
+ ior_mcast_Client_i (void);
+ ~ior_mcast_Client_i (void);
+
+ int run (CORBA::Environment &ACE_TRY_ENV);
+ // Execute the client example code.
+
+ int init (int& argc, char *argv[], CORBA::Environment &ACE_TRY_ENV);
+ // Initialize the client communication endpoint with the server.
+
+ private:
+ // mcast_ior
+ ACE_CString mcast_url_;
+
+};
+
+#endif /* IOR_MCAST_CLIENT_I_H */
diff --git a/TAO/orbsvcs/tests/IOR_MCast/server.cpp b/TAO/orbsvcs/tests/IOR_MCast/server.cpp
new file mode 100644
index 00000000000..12a52993a9f
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/server.cpp
@@ -0,0 +1,29 @@
+// $Id$
+
+#include "server_i.h"
+
+int main (int argc, char *argv[])
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ Server_i svr_i;
+
+ int init_result;
+
+ init_result = svr_i.init (argc, argv, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ if (init_result != 0)
+ return 1;
+
+ }
+ ACE_CATCH (CORBA::SystemException, ex)
+ {
+ ACE_PRINT_EXCEPTION (ex, "CORBA exception raised in server!");
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
diff --git a/TAO/orbsvcs/tests/IOR_MCast/server_i.cpp b/TAO/orbsvcs/tests/IOR_MCast/server_i.cpp
new file mode 100644
index 00000000000..17432f44284
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/server_i.cpp
@@ -0,0 +1,184 @@
+// $Id$
+
+#include "MCastC.h"
+#include "MCastS.h"
+#include "server_i.h"
+#include "MCast_Server_i.h"
+
+#include "tao/ORB_Core.h"
+#include "tao/IORTable/IORTable.h"
+
+#include "ace/Get_Opt.h"
+#include "ace/Read_Buffer.h"
+
+// Constructor
+Server_i::Server_i (void)
+{
+}
+
+// Destructor
+Server_i::~Server_i (void)
+{
+}
+
+int
+Server_i::init (int &argc,
+ char **&argv,
+ CORBA::Environment &ACE_TRY_ENV)
+{
+ this->argc_ = argc;
+ this->argv_ = argv;
+
+ ACE_TRY
+ {
+ // First initialize the ORB, that will remove some arguments...
+ this->orb_ =
+ CORBA::ORB_init (this->argc_,
+ this->argv_,
+ "" /* the ORB name, it can be anything! */,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ // Get a reference to the RootPOA.
+ CORBA::Object_var poa_object =
+ this->orb_->resolve_initial_references ("RootPOA", ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ // Narrow down to the correct reference.
+ PortableServer::POA_var poa =
+ PortableServer::POA::_narrow (poa_object.in (), ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ // Set a POA Manager.
+ PortableServer::POAManager_var poa_manager =
+ poa->the_POAManager (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ // Activate the POA Manager.
+ poa_manager->activate (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ CORBA::String_var ior;
+
+ // Create the servant
+ MCast_Server_i server_i;
+
+ // Activate it to obtain the reference
+ MCast::Server_var mcast_server =
+ server_i._this ();
+
+ CORBA::Object_var table_object =
+ this->orb_->resolve_initial_references ("IORTable", ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ IORTable::Table_var adapter =
+ IORTable::Table::_narrow (table_object.in (), ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (adapter.in ()))
+ {
+ ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
+ }
+ else
+ {
+ ior =
+ this->orb_->object_to_string (mcast_server.in (),
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ adapter->bind ("MCASTServer", ior.in (), ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+
+ // Enable such that the server can listen for multicast requests
+ // at the specified address.
+ this->enable_multicast (ior.in (),
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ // Run the ORB
+ this->orb_->run (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ //Destroy the POA, waiting until the destruction terminates.
+ poa->destroy (1, 1);
+ this->orb_->destroy ();
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "client");
+ return 1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
+
+int
+Server_i::enable_multicast (const char *ior,
+ CORBA::Environment &)
+{
+
+ ACE_TRY
+ {
+ this->parse_args (this->argc_, this->argv_);
+
+ // Get reactor instance from TAO.
+ ACE_Reactor *reactor =
+ this->orb_->orb_core ()->reactor ();
+
+ // Instantiate a handler which will handle client requests for
+ // the bottstrappable service, received on the multicast port.
+ ACE_NEW_RETURN (this->ior_multicast_,
+ TAO_IOR_Multicast (),
+ -1);
+
+ if (this->ior_multicast_->init (ior,
+ this->mcast_address_.in (),
+ TAO_SERVICEID_MCASTSERVER) == -1)
+ return -1;
+
+ // Register event handler for the ior multicast.
+ if (reactor->register_handler (this->ior_multicast_,
+ ACE_Event_Handler::READ_MASK) == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "MCast_Server: cannot register Event handler\n"));
+ return -1;
+ }
+
+ }
+ ACE_CATCH (CORBA::SystemException, ex)
+ {
+ //
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+ return 0;
+}
+
+int
+Server_i::parse_args (int argc, char *argv [])
+{
+ ACE_Get_Opt get_opts (argc, argv, "a:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'a':
+ this->mcast_address_ = get_opts.optarg;
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-a <mcast_address>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
diff --git a/TAO/orbsvcs/tests/IOR_MCast/server_i.h b/TAO/orbsvcs/tests/IOR_MCast/server_i.h
new file mode 100644
index 00000000000..0becc1f3854
--- /dev/null
+++ b/TAO/orbsvcs/tests/IOR_MCast/server_i.h
@@ -0,0 +1,56 @@
+// $Id$
+
+#if !defined (SERVER_I_H)
+#define SERVER_I_H
+
+#include "orbsvcs/orbsvcs/IOR_Multicast.h"
+
+class Server_i
+{
+ // = TITLE
+ // Server_i
+ //
+ // = DESCRIPTION
+ // Helper class for the server implementation.
+
+ public:
+ // = Constructor and destructor.
+ Server_i (void);
+ ~Server_i (void);
+
+ int init (int &argc, char **&argv, CORBA::Environment &);
+ // Initialize the server multicast.
+
+ private:
+
+ int enable_multicast (const char *ior,
+ CORBA::Environment &ACE_TRY_ENV);
+ // Sets the IOR_Multicast class to listen for multicast requests
+ // for this server.
+
+ int parse_args (int argc, char *argv[]);
+ // Parse the command line arguments.
+
+ int argc_;
+ // # of arguments on the command line.
+
+ char **argv_;
+ // arguments from command line.
+
+ CORBA::ORB_var orb_;
+ // ORB
+
+ TAO_IOR_Multicast *ior_multicast_;
+ // The ior_multicast event handler.
+
+ CORBA::String_var service_ior_;
+ // The IOR string of the service.
+
+ CORBA::String_var mcast_address_;
+ // Address of the multicast address where to listen for requests for */
+ // the server. */
+
+
+};
+
+#endif /* SERVER_I_H */