summaryrefslogtreecommitdiff
path: root/TAO/examples/Simple/echo/Echo_Client_i.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/examples/Simple/echo/Echo_Client_i.cpp')
-rw-r--r--TAO/examples/Simple/echo/Echo_Client_i.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/TAO/examples/Simple/echo/Echo_Client_i.cpp b/TAO/examples/Simple/echo/Echo_Client_i.cpp
new file mode 100644
index 00000000000..67088738cf4
--- /dev/null
+++ b/TAO/examples/Simple/echo/Echo_Client_i.cpp
@@ -0,0 +1,71 @@
+//$Id$
+
+#include "Echo_Client_i.h"
+#include "ace/Get_Opt.h"
+#include "ace/Read_Buffer.h"
+#include "ace/OS_NS_unistd.h"
+
+// This is the interface program that accesses the remote object
+
+// Constructor.
+Echo_Client_i::Echo_Client_i (void)
+{
+ //no-op
+}
+
+//Destructor.
+Echo_Client_i::~Echo_Client_i (void)
+{
+ //no-op
+}
+
+int
+Echo_Client_i::run (const char *name,
+ int argc,
+ char *argv[])
+{
+ // Initialize the client.
+ if (client.init (name,argc, argv) == -1)
+ return -1;
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+
+ ACE_TRY
+ {
+ while (1)
+ {
+ 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;
+
+ CORBA::String_var s = client->echo_string (buf
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\nString echoed by client \n%s\n",
+ s.in ()));
+ }
+
+ if (client.shutdown () == 1)
+ client->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
+
+ ACE_TRY_CHECK;
+
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"\n Exception in RMI");
+ return -1;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+
+ return 0;
+}
+