Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / DIOP / UDP_Client_i.cpp
blobb1bf9cc85ff470ffc3a7011674e7d6afd1ac84d5
1 #include "UDP_Client_i.h"
2 #include "ace/SString.h"
3 #include "ace/OS_NS_unistd.h"
5 // This is the interface program that accesses the remote object
7 // Constructor.
8 UDP_Client_i::UDP_Client_i (CORBA::ORB_ptr orb,
9 UDP_ptr udp,
10 UDP_ptr udpHandler,
11 ACE_UINT32 msec,
12 ACE_UINT32 iterations)
13 : orb_ (CORBA::ORB::_duplicate (orb))
14 , udp_ (UDP::_duplicate (udp))
15 , udpHandler_ (UDP::_duplicate (udpHandler))
16 , delay_ (msec)
17 , iterations_ (iterations)
21 //Destructor.
22 UDP_Client_i::~UDP_Client_i ()
24 //no-op
27 int
28 UDP_Client_i::svc ()
30 ACE_CString client_name ("UDP");
32 char pid[256];
33 ACE_OS::sprintf (pid,
34 "%u",
35 static_cast<u_int> (ACE_OS::getpid ()));
36 client_name += "_";
37 client_name += pid;
40 try
42 CORBA::String_var corba_client_name =
43 CORBA::string_dup (client_name.c_str ());
45 for (ACE_UINT32 i = 0;
46 i < iterations_;
47 i++)
49 udp_->invoke (corba_client_name.in (),
50 udpHandler_.inout (),
51 i);
53 ACE_DEBUG ((LM_DEBUG,
54 "invoked %C %d, going to wait %d ms\n",
55 corba_client_name.in (),
57 delay_));
58 ACE_Time_Value tv (0, delay_ * 1000);
59 ACE_OS::sleep (tv); // wait to not flood the server
62 // shut down remote ORB
63 for (int c = 0; c < 10; ++c)
64 udp_->shutdown ();
66 ACE_Time_Value tv (0, 500); // 50ms
67 ACE_OS::sleep (tv); // let the previous request go through
69 // Shut down local ORB, trigger the end of the ORB event loop
70 // in the main thread.
71 orb_->shutdown ();
73 catch (const CORBA::Exception& ex)
75 ex._tao_print_exception ("\tException");
76 return -1;
80 return 0;