Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / examples / Simple / echo / Echo_Client_i.cpp
blob09e18be9865ca83642ed7809906cf8698a887e4c
1 #include "Echo_Client_i.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/Read_Buffer.h"
4 #include "ace/OS_NS_unistd.h"
6 // This is the interface program that accesses the remote object
8 int
9 Echo_Client_i::run (const char *name,
10 int argc,
11 ACE_TCHAR *argv[])
13 // Initialize the client.
14 if (client_.init (name, argc, argv) == -1)
15 return -1;
17 try
19 while (1)
21 char buf[BUFSIZ];
23 // Get the input message which has to be displayed.
24 ACE_DEBUG ((LM_DEBUG,
25 ACE_TEXT ("ECHO? ")));
27 if (ACE_OS::fgets (buf, sizeof buf, stdin) == 0)
28 break;
30 CORBA::String_var s = client_->echo_string (buf);
32 ACE_DEBUG ((LM_DEBUG,
33 ACE_TEXT ("\nString echoed by client \n%C\n"),
34 s.in ()));
37 if (client_.do_shutdown () == 1)
38 client_->shutdown ();
40 catch (const CORBA::Exception& ex)
42 ex._tao_print_exception ("\n Exception in RMI");
43 return -1;
46 return 0;