summaryrefslogtreecommitdiff
path: root/TAO/tests/DIOP/UDP_Client_i.cpp
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2007-03-26 13:53:44 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2007-03-26 13:53:44 +0000
commitfd81755a2c71351814a316c1751923f10e57e6dc (patch)
tree10ce2fdcd2a0e9cc9cb5e145995b73abc37d83c4 /TAO/tests/DIOP/UDP_Client_i.cpp
parent7eef8f40d5d741efce95ad6369aeb81208fa5288 (diff)
downloadATCD-fd81755a2c71351814a316c1751923f10e57e6dc.tar.gz
Mon Mar 26 14:52:12 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'TAO/tests/DIOP/UDP_Client_i.cpp')
-rw-r--r--TAO/tests/DIOP/UDP_Client_i.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/TAO/tests/DIOP/UDP_Client_i.cpp b/TAO/tests/DIOP/UDP_Client_i.cpp
new file mode 100644
index 00000000000..aacb329187d
--- /dev/null
+++ b/TAO/tests/DIOP/UDP_Client_i.cpp
@@ -0,0 +1,85 @@
+// $Id$
+
+#include "UDP_Client_i.h"
+#include "ace/SString.h"
+#include "ace/OS_NS_unistd.h"
+
+// This is the interface program that accesses the remote object
+
+// Constructor.
+UDP_Client_i::UDP_Client_i (CORBA::ORB_ptr orb,
+ UDP_ptr udp,
+ UDP_ptr udpHandler,
+ ACE_UINT32 msec,
+ ACE_UINT32 iterations)
+: orb_ (CORBA::ORB::_duplicate (orb))
+, udp_ (UDP::_duplicate (udp))
+, udpHandler_ (UDP::_duplicate (udpHandler))
+, delay_ (msec)
+, iterations_ (iterations)
+{
+
+}
+
+//Destructor.
+UDP_Client_i::~UDP_Client_i (void)
+{
+ //no-op
+}
+
+int
+UDP_Client_i::svc (void)
+{
+ ACE_CString client_name ("UDP");
+
+ ACE_TCHAR pid[256];
+ ACE_OS::sprintf (pid,
+ "%u",
+ static_cast<u_int> (ACE_OS::getpid ()));
+ client_name += "_";
+ client_name += pid;
+
+
+ try
+ {
+ CORBA::String_var corba_client_name =
+ CORBA::string_dup (client_name.c_str ());
+
+ for (ACE_UINT32 i = 0;
+ i < iterations_;
+ i++)
+ {
+ udp_->invoke (corba_client_name.in (),
+ udpHandler_.inout (),
+ i);
+
+ ACE_DEBUG ((LM_DEBUG,
+ "invoked %s %d, going to wait %d ms\n",
+ corba_client_name.in (),
+ i,
+ delay_));
+ ACE_Time_Value tv (0, delay_ * 1000);
+ ACE_OS::sleep (tv); // wait to not flood the server
+ }
+
+ // shut down remote ORB
+ udp_->shutdown ();
+
+ ACE_Time_Value tv (0, 500); // 50ms
+ ACE_OS::sleep (tv); // let the previous request go through
+
+ // Shut down local ORB, trigger the end of the ORB event loop
+ // in the main thread.
+ orb_->shutdown ();
+
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("\tException");
+ return -1;
+ }
+
+
+ return 0;
+}
+