summaryrefslogtreecommitdiff
path: root/TAO/tests
diff options
context:
space:
mode:
authorkirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-09-16 00:16:11 +0000
committerkirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-09-16 00:16:11 +0000
commit063d1234fff71d1a0642c01d2e51ce8feff6dd0e (patch)
treee90d890b58888f996509c4892b864c7b768b45ef /TAO/tests
parent044e612dcbb068bdeb2feab77ddd284ed24869fb (diff)
downloadATCD-063d1234fff71d1a0642c01d2e51ce8feff6dd0e.tar.gz
Added all the files.
Diffstat (limited to 'TAO/tests')
-rw-r--r--TAO/tests/Simple/echo/Client_i.cpp275
-rw-r--r--TAO/tests/Simple/echo/Client_i.h95
-rw-r--r--TAO/tests/Simple/echo/Echo_i.cpp85
-rw-r--r--TAO/tests/Simple/echo/Echo_i.h58
-rw-r--r--TAO/tests/Simple/echo/Makefile83
-rw-r--r--TAO/tests/Simple/echo/Server_i.cpp207
-rw-r--r--TAO/tests/Simple/echo/Server_i.h82
-rw-r--r--TAO/tests/Simple/echo/client.cpp21
-rwxr-xr-xTAO/tests/Simple/echo/run_test.pl25
-rw-r--r--TAO/tests/Simple/echo/server.cpp42
10 files changed, 973 insertions, 0 deletions
diff --git a/TAO/tests/Simple/echo/Client_i.cpp b/TAO/tests/Simple/echo/Client_i.cpp
new file mode 100644
index 00000000000..f153cf3767a
--- /dev/null
+++ b/TAO/tests/Simple/echo/Client_i.cpp
@@ -0,0 +1,275 @@
+// $Id$
+
+#include "Client_i.h"
+#include "ace/Get_Opt.h"
+#include "ace/Read_Buffer.h"
+
+ACE_RCSID(Echo, Client_i, "$Id$")
+
+// Constructor.
+
+Client_i::Client_i (void)
+ : ior_ (0),
+ loop_count_ (10),
+ shutdown_ (0),
+ server_ ()
+{
+}
+
+// Reads the Server factory IOR from a file.
+int
+Client_i::read_ior (char *filename)
+{
+ // Open the file for reading.
+ ACE_HANDLE f_handle = ACE_OS::open (filename, 0);
+
+ if (f_handle == ACE_INVALID_HANDLE)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to open %s for writing: %p\n",
+ filename),
+ -1);
+
+ ACE_Read_Buffer ior_buffer (f_handle);
+ char *data = ior_buffer.read ();
+
+ if (data == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to read ior: %p\n"),
+ -1);
+
+ this->ior_ = ACE_OS::strdup (data);
+ ior_buffer.alloc ()->free (data);
+
+ ACE_OS::close (f_handle);
+
+ return 0;
+}
+
+// Parses the command line arguments and returns an error status.
+
+int
+Client_i::parse_args (void)
+{
+ ACE_Get_Opt get_opts (argc_, argv_, "dn:f:xk:xs");
+
+ // @@ Please use the same convention as for the IDL_Cubit test.
+
+
+ int c;
+ int result;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'd': // debug flag
+ TAO_debug_level++; //****
+ break;
+
+ case 'n': // loop count
+ this->loop_count_ = (u_int) ACE_OS::atoi (get_opts.optarg);
+ break;
+
+ case 'k': // ior provide on command line
+ this->ior_ = ACE_OS::strdup (get_opts.optarg);
+ break;
+ case 'f': // read the IOR from the file.
+ result = this->read_ior (get_opts.optarg);
+ if (result < 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to read ior from %s : %p\n",
+ get_opts.optarg),
+ -1);
+ break;
+
+ case 's': // don't use the naming service
+ this->use_naming_srv_ = 0;
+ break;
+
+ case 'x':
+ this->shutdown_ = 1;
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s"
+ " [-d]"
+ " [-n loopcount]"
+ " [-f ior-file]"
+ " [-k ior]"
+ " [-x]"
+ " [-s]"
+ "\n",
+ this->argv_ [0]),
+ -1);
+
+ }
+
+ // Indicates successful parsing of command line.
+ return 0;
+}
+
+//Display the message on the screen
+
+void
+Client_i::echo (const char *message)
+{
+ // @@ Please make sure to test that exception handling is working.
+ TAO_TRY
+ {
+ // Make the RMI.
+ CORBA::String_var s = this->server_->echo (message,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ ACE_DEBUG ((LM_DEBUG,
+ "%s\n",
+ s.in ()));
+ }
+ TAO_CATCHANY
+ {
+ // @@ This can all go away once you use the NO_MEMORY system
+ // exception.
+
+ // env.
+ //Echo::NullPointerException *except =
+ // Echo::NullPointerException::_narrow
+ // (TAO_TRY_ENV.exception ());
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Exception: No memory!\n"));
+ }
+ TAO_ENDTRY;
+}
+
+// Execute client example code.
+
+int
+Client_i::run (void)
+{
+
+ for (;;)
+ {
+ char buf[BUFSIZ];
+
+ // Get the input message which has to be displayed.
+ ACE_DEBUG ((LM_DEBUG,
+ "ECHO? "));
+
+ if (ACE_OS::fgets (buf, sizeof buf, stdin) == 0)
+ break;
+
+ // Make a call to the method which will display the input
+ // string.
+ this->echo (buf);
+ }
+
+ // end of the job, so tata! ;)
+
+ if (this->shutdown_)
+ this->server_->shutdown (this->env_);
+
+ return 0;
+}
+
+Client_i::~Client_i (void)
+{
+ ACE_OS::free (this->ior_);
+}
+
+int
+Client_i::via_naming_service(void)
+{
+ TAO_TRY
+ {
+ // Initialization of the naming service.
+ if (naming_srvs_client_.init (orb_.in (), argc_, argv_) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to initialize "
+ "the TAO_Naming_Client. \n"),
+ -1);
+ CosNaming::Name echo_ref_name (2);
+ echo_ref_name.length (2);
+ echo_ref_name[0].id = CORBA::string_dup ("EchoInterface");
+ echo_ref_name[1].id = CORBA::string_dup ("Echo");
+
+ CORBA::Object_var echo_obj=
+ this->naming_srvs_client_->resolve (echo_ref_name,
+ TAO_TRY_ENV);
+
+ TAO_CHECK_ENV;
+
+ // The CORBA::Object_var object is downcasted to Echo_var
+ // using the _narrow method.
+ this->server_ =
+ Echo::_narrow (echo_obj.in (),
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ }
+ TAO_CATCHANY
+ {
+ TAO_TRY_ENV.print_exception ("Echo::via_naming_service\n");
+ return -1;
+ }
+ TAO_ENDTRY;
+
+ return 0;
+}
+
+int
+Client_i::init (int argc, char **argv)
+{
+ this->argc_ = argc;
+ this->argv_ = argv;
+
+ TAO_TRY
+ {
+ // Retrieve the ORB.
+ this->orb_ = CORBA::ORB_init (this->argc_,
+ this->argv_,
+ 0,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ // Parse command line and verify parameters.
+ if (this->parse_args () == -1)
+ return -1;
+
+ TAO_debug_level = 1; //****
+
+ if (this->use_naming_srv_)
+ return via_naming_service();
+
+ if (this->ior_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%s: no ior specified\n",
+ this->argv_[0]),
+ -1);
+
+ CORBA::Object_var server_object =
+ this->orb_->string_to_object (this->ior_,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ if (CORBA::is_nil (server_object.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "invalid ior <%s>\n",
+ this->ior_),
+ -1);
+
+ // @@ Please add a comment here.
+ // the downcasting from CORBA::Object_var to Echo_var
+ // is done using the _narrow method.
+ this->server_ = Echo::_narrow (server_object.in (),
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ }
+ TAO_CATCHANY
+ {
+ TAO_TRY_ENV.print_exception ("Client_i::init");
+ return -1;
+ }
+ TAO_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/tests/Simple/echo/Client_i.h b/TAO/tests/Simple/echo/Client_i.h
new file mode 100644
index 00000000000..53dc8d52af1
--- /dev/null
+++ b/TAO/tests/Simple/echo/Client_i.h
@@ -0,0 +1,95 @@
+// -*- C++ -*-
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/tests/Simple
+//
+// = FILENAME
+// Client_i.h
+//
+// = DESCRIPTION
+// This class implements a simple CORBA client that access a Echo
+// server.
+//
+// = AUTHORS
+// Kirthika Parameswaran <kirthika@cs.wustl.edu>
+//
+// ============================================================================
+
+#include "EchoC.h"
+#include "orbsvcs/Naming/Naming_Utils.h"
+#include "orbsvcs/CosNamingC.h"
+
+#include <string.h>
+
+class Client_i
+{
+ // = TITLE
+ // Echo client implementation.
+ //
+ // = DESCRIPTION
+ // Class wrapper for a client that gets the server IOR and then
+ // makes several calls to the server before optionally shutting
+ // it down.
+public:
+ // = Initialization and termination methods.
+ Client_i (void);
+ // Constructor.
+
+ ~Client_i (void);
+ // Destructor.
+
+ int run (void);
+ // Execute client example code.
+
+ int init (int argc, char *argv[]);
+ // Initialize the client communication endpoint with server.
+
+private:
+ int read_ior (char *filename);
+ // Function to read the server IOR from a file.
+
+ int parse_args (void);
+ // Parses the arguments passed on the command line.
+
+ int via_naming_service(void);
+ // This method initialises the naming service
+ // and registers the object with the POA.
+
+ void echo (const char *message);
+ // Displays the message on the screen.
+
+ int argc_;
+ // # of arguments on the command line.
+
+ char **argv_;
+ // arguments from command line.
+
+ char *ior_;
+ // IOR of the obj ref of the server.
+
+ u_int loop_count_;
+ // Number of times to invoke the <echo> operation.
+
+ int shutdown_;
+ // Flag for server shutdown.
+
+ CORBA::Environment env_;
+ // Environment variable.
+
+ TAO_Naming_Client naming_srvs_client_;
+ // An instance of the name client used for resolving the factory
+ // objects.
+
+ int use_naming_srv_;
+ // This variable denotes whether the naming service
+ // is used or not.
+
+ Echo_var server_;
+ // Server object reference.
+
+ CORBA::ORB_var orb_;
+ // Remember our orb.
+};
diff --git a/TAO/tests/Simple/echo/Echo_i.cpp b/TAO/tests/Simple/echo/Echo_i.cpp
new file mode 100644
index 00000000000..55984b0e789
--- /dev/null
+++ b/TAO/tests/Simple/echo/Echo_i.cpp
@@ -0,0 +1,85 @@
+// $Id$
+
+#include "Echo_i.h"
+
+ACE_RCSID(Echo, Echo_i, "$Id$")
+
+// Constructor.
+
+Echo_i::Echo_i (void)
+{
+}
+
+// Destructor.
+
+Echo_i::~Echo_i (void)
+{
+}
+
+// Set the ORB pointer.
+
+void Echo_i::orb (CORBA::ORB_ptr o)
+{
+ this->orb_ = CORBA::ORB::_duplicate (o);
+}
+
+// Return the mesg string from the server
+
+char *
+Echo_i::echo (const char *mesg,
+ CORBA::Environment &env)
+{
+ // @@ Once you're done with getting your program to compile and run,
+ // I want you to use Purify on your program to find out where the
+ // memory management problems are.
+
+ // @@ Please read the ACE-guidelines.html and follow the programming
+ // style.
+
+ if (mesg == 0)
+ return 0;
+ // The pointer mesg was NULL, return.
+
+ // @@ If you raise an exception for whatever reason, you need to
+ // return 0.
+
+
+ CORBA::String_var str = CORBA::string_dup (mesg);
+
+ // if CORBA::string_dup() returns a 0 pointer, an exception is
+ // raised.
+
+ if (str == 0)
+ env.exception (new CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
+
+
+ // @@ Make sure that you test out an version of this test where you
+ // intentionally raise an exception to make sure that your client
+ // handles it properly.
+
+ // @@ You need to take a look at how to handle memory failures,
+ // i.e., when CORBA::string_dup() returns a 0 pointer. In this
+ // case, you'll need to transform this into an exception and raise
+ // the exception. I recommend that you check out
+ // $TAO_ROOT/orbsvcs/orbsvcs/Log/Logger_i.cpp and see how it is
+ // handled there.
+
+ // Got thru! now, make a deep copy of the mesg string and send it
+ // back to the client.
+
+ return str._retn ();
+ // The _retn is used as it allows the conversion of
+ // CORBA::String_var to char* without causing any compiler errors.
+}
+
+// Shutdown the server application.
+
+void Echo_i::shutdown (CORBA::Environment &)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "\n%s\n",
+ "The echo server(Echo_i) is shutting down"));
+
+ // Instruct the ORB to shutdown.
+ this->orb_->shutdown ();
+}
diff --git a/TAO/tests/Simple/echo/Echo_i.h b/TAO/tests/Simple/echo/Echo_i.h
new file mode 100644
index 00000000000..c8214fefde9
--- /dev/null
+++ b/TAO/tests/Simple/echo/Echo_i.h
@@ -0,0 +1,58 @@
+// -*- C++ -*-
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/tests/Simple/echo
+//
+// = FILENAME
+// Echo_i.h
+//
+// = DESCRIPTION
+// This class implements the Echo IDL interface.
+//
+// = AUTHOR
+// Kirthika Parameswaran <kirthika@cs.wustl.edu>
+//
+// ============================================================================
+
+#if !defined (ECHO_I_H)
+#define ECHO_I_H
+
+#include "EchoS.h"
+
+class Echo_i : public POA_Echo
+{
+ // = TITLE
+ // Echo Object Implementation
+ //
+ // = DESCRIPTION
+ // The object implementation performs teh following functions:
+ // -- To return the string which needs to be displayed
+ // from the server.
+ // -- shuts down the server
+public:
+ // = Initialization and termination methods.
+ Echo_i (void);
+ // Constructor.
+
+ ~Echo_i (void);
+ // Destructor.
+
+ virtual char *echo (const char *mesg,
+ CORBA::Environment &env);
+ // Return the mesg string back from the server.
+
+ virtual void shutdown (CORBA::Environment &env);
+ // Shutdown the server.
+
+ void orb (CORBA::ORB_ptr o);
+ // Set the ORB pointer.
+
+private:
+ CORBA::ORB_var orb_;
+ // ORB pointer.
+};
+
+#endif /* ECHO_I_H */
diff --git a/TAO/tests/Simple/echo/Makefile b/TAO/tests/Simple/echo/Makefile
new file mode 100644
index 00000000000..3b373c01092
--- /dev/null
+++ b/TAO/tests/Simple/echo/Makefile
@@ -0,0 +1,83 @@
+#----------------------------------------------------------------------------
+#
+# $Id$
+#
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+ifndef TAO_ROOT
+ TAO_ROOT = $(ACE_ROOT)/TAO
+endif # ! TAO_ROOT
+
+LDLIBS = -lTAO -lorbsvcs
+
+IDL_SRC = EchoC.cpp EchoS.cpp
+
+PROG_SRCS = \
+ client.cpp \
+ Client_i.cpp \
+ server.cpp \
+ Server_i.cpp \
+ Echo_i.cpp \
+
+SRC = $(IDL_SRC) $(PROG_SRCS)
+
+SIMPLE_CLT_OBJS = \
+ EchoC.o \
+ EchoS.o \
+ Client_i.o \
+ client.o
+SIMPLE_SVR_OBJS = \
+ EchoC.o \
+ EchoS.o \
+ Echo_i.o \
+ Server_i.o \
+ server.o
+
+BIN = server \
+ client
+BUILD = $(BIN)
+VLDLIBS = $(LDLIBS:%=%$(VAR))
+VBIN = $(BIN:%=%$(VAR))
+
+#----------------------------------------------------------------------------
+# 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
+#----------------------------------------------------------------------------
+
+LDFLAGS += -L$(TAO_ROOT)/tao -L$(ACE_ROOT)/ace
+CPPFLAGS += -I$(TAO_ROOT)/orbsvcs
+
+.PRECIOUS: EchoC.cpp EchoC.i EchoC.h
+.PRECIOUS: EchoS.cpp EchoS.i EchoS.h
+.PRECIOUS: EchoS_T.cpp EchoS_T.i EchoS_T.h
+
+server: $(addprefix $(VDIR),$(SIMPLE_SVR_OBJS))
+ $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK)
+
+client: $(addprefix $(VDIR),$(SIMPLE_CLT_OBJS))
+ $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK)
+
+realclean: clean
+ -/bin/rm -rf EchoC.* EchoS.* EchoS_T.*
+
+# 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/tests/Simple/echo/Server_i.cpp b/TAO/tests/Simple/echo/Server_i.cpp
new file mode 100644
index 00000000000..b405ad1efb2
--- /dev/null
+++ b/TAO/tests/Simple/echo/Server_i.cpp
@@ -0,0 +1,207 @@
+#include "Server_i.h"
+#include "ace/Get_Opt.h"
+
+ACE_RCSID(Echo, Server_i, "$Id$")
+
+// Constructor.
+
+Server_i::Server_i (void)
+ : ior_output_file_ (0)
+{
+ // no-op.
+}
+
+// Destructor.
+
+Server_i::~Server_i (void)
+{
+ // no-op.
+}
+
+// The naming service is initialized and the naming context as well as
+// the object name is bound to the naming server.
+
+int
+Server_i::thru_naming_service (CORBA::Environment& env)
+{
+
+ CORBA::ORB_var orb;
+ PortableServer::POA_var child_poa;
+
+ // @@ I think you should probably use a TAO_TRY block here in case
+ // we enable C++ exception handling. Please check with Carlos to
+ // make sure the right programming style.
+
+ TAO_TRY
+ {
+ orb = this->orb_manager_.orb ();
+
+ child_poa = this->orb_manager_.child_poa ();
+
+ TAO_debug_level = 1; // ******
+ int return_val = this->naming_srvr_.init (orb.in (),
+ child_poa.in ());
+ if (return_val == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Failed to initialize TAO_Naming_Server\n"),
+ -1);
+
+ // Register the object implementation with the POA.
+ Echo_var echo_obj = this->servant_->_this (env);
+ TAO_CHECK_ENV_RETURN (env, -1);
+
+ // Name the context.
+ CosNaming::Name naming_context_name (1);
+ naming_context_name.length (1);
+ naming_context_name[0].id = CORBA::string_dup ("EchoInterface");
+
+ // Name the object.
+ CosNaming::Name echo_obj_name (1);
+ echo_obj_name.length (1);
+ echo_obj_name[0].id = CORBA::string_dup ("Echo");
+
+ // Get the context attached to the server.
+ this->naming_context_ =
+ this->naming_srvr_->bind_new_context (naming_context_name,
+ env);
+ TAO_CHECK_ENV_RETURN (env,-1);
+
+ // Now, attach the object name to the context.
+ this->naming_context_->bind (echo_obj_name,
+ echo_obj.in(),
+ env);
+ TAO_CHECK_ENV_RETURN (env,-1);
+
+ }
+ TAO_CATCHANY
+ {
+ // TAO_TRY_ENV.print_execption ("Server_i::thru_naming_service\n");
+ return -1;
+ }
+ TAO_ENDTRY;
+
+ return 0;
+}
+
+// Parse the command-line arguments and set options.
+int
+Server_i::parse_args (void)
+{
+ ACE_Get_Opt get_opts (this->argc_, this->argv_, "do: ");
+ int c;
+
+ // @@ I think that by default, we should use the naming service.
+ // Can you please check how things work for IDL_Cubit and follow the
+ // same conventions?
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'd': // debug flag.
+ TAO_debug_level++; ///*****
+ break;
+
+ case 'o': // output the IOR toi a file.
+ this->ior_output_file_ = ACE_OS::fopen (get_opts.optarg, "w");
+ if (this->ior_output_file_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to open %s for writing: %p\n",
+ get_opts.optarg),
+ -1);
+ break;
+
+ case 's': // don't use the naming service
+ this->using_naming_srv_ = 0;
+ break;
+
+ case '?': // display help for use of the server.
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s"
+ " [-d]"
+ " [-o] <ior_output_file>"
+ " [-s]"
+ "\n",
+ argv_ [0]),
+ 1);
+ }
+ // Indicates successful parsing of command line.
+ return 0;
+}
+
+// Initialize the server.
+
+int
+Server_i::init (int argc,
+ char *argv[],
+ CORBA::Environment &env)
+{
+ // Allocate an Echo_i object.
+
+ ACE_NEW_RETURN (this->servant_,
+ Echo_i,
+ -1);
+
+ // @@ Please use the init() method instead of init_child_poa() method since you don't really need it.
+
+ // Call the init of <TAO_ORB_Manager> to initialize the ORB and
+ // create the child poa under the root POA.
+ if (this->orb_manager_.init_child_poa (argc,
+ argv,
+ "child_poa",
+ env) == -1)
+
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "init_child_poa"),
+ -1);
+
+ TAO_CHECK_ENV_RETURN (env, -1);
+
+ this->argc_ = argc;
+ this->argv_ = argv;
+
+ int retval = this->parse_args ();
+
+ if (retval != 0)
+ return retval;
+
+ CORBA::ORB_var orb = this->orb_manager_.orb ();
+
+ // Stash our ORB pointer for later reference.
+ this->servant_->orb (orb.in ());
+
+ // @@ Please change this, as well!
+ // Activate the servant in the POA.
+ CORBA::String_var str =
+ this->orb_manager_.activate_under_child_poa ("echo",
+ this->servant_,
+ env);
+ ACE_DEBUG ((LM_DEBUG,
+ "The IOR is: <%s>\n",
+ str.in ()));
+
+ if (this->ior_output_file_)
+ {
+ ACE_OS::fprintf (this->ior_output_file_,
+ "%s",
+ str.in ());
+ ACE_OS::fclose (this->ior_output_file_);
+ }
+
+ if (this->using_naming_srv_)
+ return this->thru_naming_service (env);
+
+ return 0;
+}
+
+int
+Server_i::run (CORBA::Environment &env)
+{
+ // Run the main event loop for the ORB.
+ if (this->orb_manager_.run (env) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Server_i::run"),
+ -1);
+ return 0;
+}
diff --git a/TAO/tests/Simple/echo/Server_i.h b/TAO/tests/Simple/echo/Server_i.h
new file mode 100644
index 00000000000..508f6e7d556
--- /dev/null
+++ b/TAO/tests/Simple/echo/Server_i.h
@@ -0,0 +1,82 @@
+// -*- C++ -*-
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/tests/Simple
+//
+// = FILENAME
+// Server_i.h
+//
+// = DESCRIPTION
+// A CORBA server that initializes the echo server implementation
+// and the ORB.
+//
+// = AUTHORS
+// Kirthika Parameswaran <kirthika@cs.wustl.edu>
+//
+// ============================================================================
+
+#if !defined (SERVER_I_H)
+#define SERVER_I_H
+
+#include "Echo_i.h"
+#include "EchoS.h"
+#include "tao/TAO.h"
+#include "orbsvcs/CosNamingS.h"
+#include "orbsvcs/Naming/Naming_Utils.h"
+
+class Server_i
+{
+ // = TITLE
+ // CORBA Server implementation.
+public:
+ // = Initialization and termination methods.
+ Server_i (void);
+ // Constructor.
+
+ ~Server_i (void);
+ // Destructor.
+
+ int init (int argc, char *argv[], CORBA::Environment &env);
+ // Initialize the Server state - parsing arguments and waiting.
+
+ int run (CORBA::Environment &env);
+ // Run the orb.
+
+private:
+ int parse_args (void);
+ // Parses the commandline arguments.
+
+ int thru_naming_service (CORBA::Environment &env);
+ // Initialises the name server and registers the Echo server object
+ // name with the name server.
+
+ TAO_ORB_Manager orb_manager_;
+ // The ORB manager.
+
+ Echo_i *servant_;
+ // Servant for the Echo interface.
+
+ FILE *ior_output_file_;
+ // File where the IOR of the server object is stored.
+
+ int argc_;
+ // Number of command line arguments.
+
+ char **argv_;
+ // The command line arguments.
+
+ CosNaming::NamingContext_var naming_context_;
+ // Naming context for the naming service.
+
+ TAO_Naming_Server naming_srvr_;
+ // An instance of the name server, wherein the naming context
+ // containg the factory of objects will be registered.
+
+ int using_naming_srv_;
+ // This specifies whether the naming service is to be used.
+};
+
+#endif /* ECHO_IMPL_H */
diff --git a/TAO/tests/Simple/echo/client.cpp b/TAO/tests/Simple/echo/client.cpp
new file mode 100644
index 00000000000..b9623e4a678
--- /dev/null
+++ b/TAO/tests/Simple/echo/client.cpp
@@ -0,0 +1,21 @@
+// $Id$
+
+#include "Client_i.h"
+
+ACE_RCSID(Echo, client, "$Id$")
+
+// This function runs the echo test.
+
+int
+main (int argc, char **argv)
+{
+ Client_i client;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\n\techo client\n\n"));
+
+ if (client.init (argc, argv) == -1)
+ return -1;
+ else
+ return client.run ();
+}
diff --git a/TAO/tests/Simple/echo/run_test.pl b/TAO/tests/Simple/echo/run_test.pl
new file mode 100755
index 00000000000..0b51b245b17
--- /dev/null
+++ b/TAO/tests/Simple/echo/run_test.pl
@@ -0,0 +1,25 @@
+#$Id$
+# -*- perl -*-
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+
+#unshift @INC, '../../../../bin';
+use lib "../../../../bin";
+require ACEutils;
+require Process;
+
+$iorfile = "echo.ior";
+
+$SV = Process::Create ("server$Process::EXE_EXT", "-o $iorfile ");
+
+ACE::waitforfile ($iorfile);
+
+$status = system ("client$Process::EXE_EXT -f $iorfile -x");
+
+$SV->Kill (); $SV->Wait ();
+
+unlink $iorfile;
+
+exit $status;
diff --git a/TAO/tests/Simple/echo/server.cpp b/TAO/tests/Simple/echo/server.cpp
new file mode 100644
index 00000000000..4fe88ccbf73
--- /dev/null
+++ b/TAO/tests/Simple/echo/server.cpp
@@ -0,0 +1,42 @@
+// $Id$
+
+#include "Server_i.h"
+
+ACE_RCSID(Echo, server, "$Id$")
+
+// This is the main driver program for the echo server.
+
+int
+main (int argc, char *argv[])
+{
+ Server_i server;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\n\techo server\n\n"));
+
+ TAO_TRY
+ {
+ if (server.init (argc, argv, TAO_TRY_ENV) == -1)
+ return 1;
+ else
+ {
+ server.run (TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ }
+ }
+ TAO_CATCH (CORBA::SystemException, sysex)
+ {
+ ACE_UNUSED_ARG (sysex);
+ TAO_TRY_ENV.print_exception ("System Exception");
+ return -1;
+ }
+ TAO_CATCH (CORBA::UserException, userex)
+ {
+ ACE_UNUSED_ARG (userex);
+ TAO_TRY_ENV.print_exception ("User Exception");
+ return -1;
+ }
+ TAO_ENDTRY;
+
+ return 0;
+}