summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/examples/ORT/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/examples/ORT/client.cpp')
-rw-r--r--TAO/orbsvcs/examples/ORT/client.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/TAO/orbsvcs/examples/ORT/client.cpp b/TAO/orbsvcs/examples/ORT/client.cpp
new file mode 100644
index 00000000000..49cb266aa2e
--- /dev/null
+++ b/TAO/orbsvcs/examples/ORT/client.cpp
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+
+#include "sum_serverC.h"
+#include "ace/Get_Opt.h"
+
+ACE_RCSID (ORT,
+ client,
+ "$Id$")
+
+const char *ior = "file://test.ior";
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "k:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'k':
+ ior = get_opts.optarg;
+ break;
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Usage: %s "
+ "-k IOR "
+ "\n",
+ argv[0]),
+ -1);
+ }
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv, "client_sum_orb");
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ CORBA::Object_var obj =
+ orb->string_to_object (ior);
+
+ ORT::sum_server_var server =
+ ORT::sum_server::_narrow (obj.in ());
+
+ if (CORBA::is_nil (server.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Object reference <%s> is nil.\n",
+ ior),
+ 1);
+ }
+
+ CORBA::ULong a = 5;
+ CORBA::ULong b = 3;
+
+ CORBA::ULong result = server->add_variables (a,
+ b);
+
+ if (result != 8)
+ ACE_DEBUG ((LM_DEBUG,
+ "Error: Add Variables did not return the right value\n"));
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("ORT example on client side :");
+ return -1;
+ }
+
+ return 0;
+}