summaryrefslogtreecommitdiff
path: root/TAO/examples
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-11-26 00:31:07 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-11-26 00:31:07 +0000
commit94ec94edfde4371daef0f790daeb6ddabd085989 (patch)
tree0e7b1a3646e5af0c30f59d1c080f6b3fb56dcc70 /TAO/examples
parent9919ead43669136a9cab73c92d4158fa2cd32e3a (diff)
downloadATCD-94ec94edfde4371daef0f790daeb6ddabd085989.tar.gz
.
Diffstat (limited to 'TAO/examples')
-rw-r--r--TAO/examples/Simple/echo/Client_i.cpp50
-rw-r--r--TAO/examples/Simple/echo/Client_i.h6
-rw-r--r--TAO/examples/Simple/echo/Echo.idl15
-rw-r--r--TAO/examples/Simple/echo/Echo_i.cpp53
-rw-r--r--TAO/examples/Simple/echo/Echo_i.h8
-rw-r--r--TAO/examples/Simple/echo/README14
-rw-r--r--TAO/examples/Simple/echo/Server_i.cpp6
-rwxr-xr-xTAO/examples/Simple/echo/run_test.pl8
8 files changed, 110 insertions, 50 deletions
diff --git a/TAO/examples/Simple/echo/Client_i.cpp b/TAO/examples/Simple/echo/Client_i.cpp
index 373a2f2cd4f..05868ad0dcc 100644
--- a/TAO/examples/Simple/echo/Client_i.cpp
+++ b/TAO/examples/Simple/echo/Client_i.cpp
@@ -12,7 +12,7 @@ Client_i::Client_i (void)
: ior_ (0),
loop_count_ (10),
shutdown_ (0),
- use_naming_service_ (1),
+ use_naming_service_ (0),
server_ ()
{
}
@@ -81,7 +81,7 @@ Client_i::parse_args (void)
break;
case 's': // don't use the naming service
- this->use_naming_service_ = 0;
+ this->use_naming_service_ = 1;
break;
case 'x':
@@ -107,17 +107,44 @@ Client_i::parse_args (void)
return 0;
}
-//Display the message on the screen
+void
+Client_i::echo_list (const char *message)
+{
+ TAO_TRY
+ {
+ // Make the RMI.
+ Echo::List *l = this->server_->echo_list
+ (message,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ for (u_int i = 0; i < l->length (); i++)
+ {
+ CORBA::Object_ptr obj = (*l)[i];
+
+ ACE_DEBUG ((LM_DEBUG,
+ "list elem %d = %s\n",
+ i,
+ orb_->object_to_string (obj)));
+ }
+ }
+ TAO_CATCHANY
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Exception raised!\n"));
+ }
+ TAO_ENDTRY;
+}
void
-Client_i::echo (const char *message)
+Client_i::echo_string (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);
+ CORBA::String_var s = this->server_->echo_string
+ (message,
+ TAO_TRY_ENV);
TAO_CHECK_ENV;
ACE_DEBUG ((LM_DEBUG,
"%s\n",
@@ -131,6 +158,15 @@ Client_i::echo (const char *message)
TAO_ENDTRY;
}
+//Display the message on the screen
+
+void
+Client_i::echo (const char *message)
+{
+ this->echo_list (message);
+ this->echo_string (message);
+}
+
// Execute client example code.
int
diff --git a/TAO/examples/Simple/echo/Client_i.h b/TAO/examples/Simple/echo/Client_i.h
index 1b569f23ace..eb1b6d0ae15 100644
--- a/TAO/examples/Simple/echo/Client_i.h
+++ b/TAO/examples/Simple/echo/Client_i.h
@@ -61,6 +61,12 @@ private:
void echo (const char *message);
// Displays the message on the screen.
+ void echo_list (const char *message);
+ // Displays the message on the screen.
+
+ void echo_string (const char *message);
+ // Displays the message on the screen.
+
int argc_;
// # of arguments on the command line.
diff --git a/TAO/examples/Simple/echo/Echo.idl b/TAO/examples/Simple/echo/Echo.idl
index c0c5211a427..a396838f0bb 100644
--- a/TAO/examples/Simple/echo/Echo.idl
+++ b/TAO/examples/Simple/echo/Echo.idl
@@ -7,11 +7,18 @@
interface Echo
{
// = TITLE
- // Defines an interface that encapsulates operations that
- // return the mesg string to be displayed and shuts down the server.
+ // Defines an interface that encapsulates operations that return the
+ // mesg string to be displayed and shuts down the server.
- string echo (in string mesg);
- // This operation returns the message and displays it on the screen.
+ typedef sequence<Object> List;
+
+ List echo_list (in string message);
+ // This operation returns the message as a sequence of Objects and
+ // displays it on the screen as a string.
+
+ string echo_string (in string message);
+ // This operation returns the message as a string and displays it on
+ // the screen.
oneway void shutdown ();
// This operation will shutdown the server.
diff --git a/TAO/examples/Simple/echo/Echo_i.cpp b/TAO/examples/Simple/echo/Echo_i.cpp
index b8b72e423d2..9d3e0bb4614 100644
--- a/TAO/examples/Simple/echo/Echo_i.cpp
+++ b/TAO/examples/Simple/echo/Echo_i.cpp
@@ -23,45 +23,46 @@ void Echo_i::orb (CORBA::ORB_ptr o)
this->orb_ = CORBA::ORB::_duplicate (o);
}
-// Return the mesg string from the server
+// Return a list of object references.
-char *
-Echo_i::echo (const char *mesg,
- CORBA::Environment &env)
+Echo::List *
+Echo_i::echo_list (const char *message,
+ 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.
+ Echo::List *list;
+
+ ACE_NEW_RETURN (list,
+ Echo::List (3),
+ 0);
+
+ list->length (3);
+
+ // Just do something to get a list of object references.
+ (*list)[0] = orb_->resolve_initial_references ("NameService");
+ (*list)[1] = orb_->resolve_initial_references ("NameService");;
+ (*list)[2] = orb_->resolve_initial_references ("NameService");;
+
+ return list;
+}
- // @@ Please read the ACE-guidelines.html and follow the programming
- // style.
+// Return the mesg string from the server
+char *
+Echo_i::echo_string (const char *mesg,
+ CORBA::Environment &env)
+{
+ // The pointer mesg was NULL, return.
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
+ // if <CORBA::string_dup> returns a 0 pointer, an exception is
// raised.
- if (str.in() == 0)
+ if (str.in () == 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.
diff --git a/TAO/examples/Simple/echo/Echo_i.h b/TAO/examples/Simple/echo/Echo_i.h
index d54b811fef8..d7d5498b70d 100644
--- a/TAO/examples/Simple/echo/Echo_i.h
+++ b/TAO/examples/Simple/echo/Echo_i.h
@@ -40,8 +40,12 @@ public:
~Echo_i (void);
// Destructor.
- virtual char *echo (const char *mesg,
- CORBA::Environment &env);
+ virtual Echo::List *echo_list (const char *mesg,
+ CORBA::Environment &env);
+ // Return the mesg string back from the server.
+
+ virtual char *echo_string (const char *mesg,
+ CORBA::Environment &env);
// Return the mesg string back from the server.
virtual void shutdown (CORBA::Environment &env);
diff --git a/TAO/examples/Simple/echo/README b/TAO/examples/Simple/echo/README
index b84243b21ee..71e990e537d 100644
--- a/TAO/examples/Simple/echo/README
+++ b/TAO/examples/Simple/echo/README
@@ -7,14 +7,15 @@ shuts down the server.
server:
-------
-server [-d] [-o <ior_output_file>]
+server [-d] [-o <ior_output_file>] [-s]
Options:
-------
-d Debug flag (It is additive more -d flags will give debugging).
-o Outputs the ior to the file
- The ior is the refernce using which the client can interact with
+ The ior is the reference using which the client can interact with
the target server object.
+-s Use the naming service
When the server is started, you should see as the first line of output
something that looks like
@@ -33,7 +34,7 @@ options are ignored.
client:
-------
-client [-d] [-x] [-f <Server_ior_file>] [-n iterations] [-k ior]
+client [-d] [-x] [-f <Server_ior_file>] [-n iterations] [-k ior] [-s]
Options:
-------
@@ -42,11 +43,12 @@ Options:
-f Reads the server ior from the file
-n no. of iterations
-k IOR
+-s Use the naming service
You can either cut and paste the IOR from the server to the client
-(with the -k option), or have the client read the IOR from a file
-using the -f option. (This file is produced using the -o option of the
-server.)
+(with the -k option), have the client read the IOR from a file using
+the -f option (this file is produced using the -o option of the
+server), or use the naming service (with the -s option).
run_test.pl:
------------
diff --git a/TAO/examples/Simple/echo/Server_i.cpp b/TAO/examples/Simple/echo/Server_i.cpp
index 35d93bcd9af..91356b421d1 100644
--- a/TAO/examples/Simple/echo/Server_i.cpp
+++ b/TAO/examples/Simple/echo/Server_i.cpp
@@ -9,7 +9,7 @@ Server_i::Server_i (void)
: ior_output_file_ (0),
argc_ (0),
argv_ (0),
- using_naming_service_ (1)
+ using_naming_service_ (0)
{
// no-op.
}
@@ -74,7 +74,7 @@ Server_i::init_naming_service (CORBA::Environment& env)
int
Server_i::parse_args (void)
{
- ACE_Get_Opt get_opts (this->argc_, this->argv_, "do: ");
+ ACE_Get_Opt get_opts (this->argc_, this->argv_, "do:s");
int c;
while ((c = get_opts ()) != -1)
@@ -92,7 +92,7 @@ Server_i::parse_args (void)
-1);
break;
case 's': // don't use the naming service
- this->using_naming_service_ = 0;
+ this->using_naming_service_ = 1;
break;
case '?': // display help for use of the server.
default:
diff --git a/TAO/examples/Simple/echo/run_test.pl b/TAO/examples/Simple/echo/run_test.pl
index e79b6bedcd2..a79b739357b 100755
--- a/TAO/examples/Simple/echo/run_test.pl
+++ b/TAO/examples/Simple/echo/run_test.pl
@@ -8,11 +8,15 @@ use lib "../../../../bin";
require ACEutils;
require Process;
+$iorfile = "echo.ior";
+
+$SV = Process::Create ("server$Process::EXE_EXT", "-o $iorfile ");
-$SV = Process::Create ($EXEPREFIX."server$Process::EXE_EXT", " ");
sleep ($ACE::sleeptime);
-$status = system ($EXEPREFIX."client$Process::EXE_EXT -x");
+$status = system ("client$Process::EXE_EXT -f $iorfile -x");
$SV->Kill (); $SV->Wait ();
+unlink $iorfile;
+
exit $status;