diff options
author | vishal <vishal@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-09-01 01:56:31 +0000 |
---|---|---|
committer | vishal <vishal@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-09-01 01:56:31 +0000 |
commit | afd155454caf571f3a1151513a5970a4ec14ad45 (patch) | |
tree | ecb1d474c10d3491cfa34f97ae077a892f037fba /examples | |
parent | 8085b7de05683c0330794e57732deedb571281a9 (diff) | |
download | ATCD-afd155454caf571f3a1151513a5970a4ec14ad45.tar.gz |
*** empty log message ***
Diffstat (limited to 'examples')
-rw-r--r-- | examples/QOS/QOS_Event_Handler.cpp | 56 | ||||
-rw-r--r-- | examples/QOS/Read_Handler.h | 51 | ||||
-rw-r--r-- | examples/QOS/Receiver_QOS_Event_Handler.cpp (renamed from examples/QOS/Read_Handler.cpp) | 40 | ||||
-rw-r--r-- | examples/QOS/Receiver_QOS_Event_Handler.h | 57 | ||||
-rw-r--r-- | examples/QOS/Sender_QOS_Event_Handler.cpp | 83 | ||||
-rw-r--r-- | examples/QOS/Sender_QOS_Event_Handler.h (renamed from examples/QOS/QOS_Event_Handler.h) | 18 | ||||
-rw-r--r-- | examples/QOS/client.cpp | 54 |
7 files changed, 195 insertions, 164 deletions
diff --git a/examples/QOS/QOS_Event_Handler.cpp b/examples/QOS/QOS_Event_Handler.cpp deleted file mode 100644 index 7d9c0824d85..00000000000 --- a/examples/QOS/QOS_Event_Handler.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ACE_wrappers/tests/ -// -// = FILENAME -// QOS_Event_Handler.cpp -// -// = AUTHOR -// Vishal Kachroo -// -// ============================================================================ - -#include "QOS_Event_Handler.h" - -// Constructor. -ACE_QOS_Event_Handler::ACE_QOS_Event_Handler () -{} - -ACE_QOS_Event_Handler::ACE_QOS_Event_Handler (const ACE_SOCK_Dgram_Mcast &dgram_mcast) -{ - this->read_handler_.dgram_mcast (dgram_mcast); -} - -// Destructor. -ACE_QOS_Event_Handler::~ACE_QOS_Event_Handler () -{ -} - -// Return the handle of the Dgram_Mcast. This method is -// called internally by the reactor. - -ACE_HANDLE -ACE_QOS_Event_Handler::get_handle (void) const -{ - return this->read_handler_.get_handle (); -} - -int -ACE_QOS_Event_Handler::handle_qos (ACE_HANDLE) -{ - - ACE_DEBUG ((LM_DEBUG, - "Inside handle_qos ()\nRegistering the Read Handler\n")); - - if (ACE_Reactor::instance ()->register_handler (&this->read_handler_, - ACE_Event_Handler::READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "Error in registering the read_handler_\n"), - -1); - - return 0; -} diff --git a/examples/QOS/Read_Handler.h b/examples/QOS/Read_Handler.h deleted file mode 100644 index 7926b1b6630..00000000000 --- a/examples/QOS/Read_Handler.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ACE_wrappers/tests/ -// -// = FILENAME -// Read_Handler.h -// -// = AUTHOR -// Vishal Kachroo -// -// ============================================================================ - -#ifndef READ_HANDLER_H -#define READ_HANDLER_H - -#include "ace/INET_Addr.h" -#include "ace/SOCK_Dgram_Mcast.h" -#include "ace/Event_Handler.h" -#include "ace/Reactor.h" - -ACE_RCSID(Read_Handler, Read_Handler, "$Id$") - - class ACE_Read_Handler : public ACE_Event_Handler - { - public: - - ACE_Read_Handler (void); - ~ACE_Read_Handler (void); - // Initialization and Termination methods. - - virtual int handle_input (ACE_HANDLE fd); - // Handles a READ event. - - virtual ACE_HANDLE get_handle (void) const; - // Override this to return the handle of the Dgram_Mcast - // that we are using. - - virtual void dgram_mcast (const ACE_SOCK_Dgram_Mcast &dgram_mcast); - // Set the dgram_mcast; - - private: - - ACE_SOCK_Dgram_Mcast dgram_mcast_; - ACE_INET_Addr remote_addr_; - }; - -#endif /* READ_HANDLER_H */ diff --git a/examples/QOS/Read_Handler.cpp b/examples/QOS/Receiver_QOS_Event_Handler.cpp index 7559007bf58..dfab0cfeb52 100644 --- a/examples/QOS/Read_Handler.cpp +++ b/examples/QOS/Receiver_QOS_Event_Handler.cpp @@ -4,38 +4,54 @@ // ============================================================================ // // = LIBRARY -// ACE_wrappers/examples/QOS/ +// ACE_wrappers/examples/QOS // // = FILENAME -// Read_Handler.cpp +// Receiver_QOS_Event_Handler.cpp // // = AUTHOR // Vishal Kachroo // // ============================================================================ -#include "Read_Handler.h" +#include "Receiver_QOS_Event_Handler.h" // Constructor. -ACE_Read_Handler::ACE_Read_Handler () -{}; +ACE_QOS_Event_Handler::ACE_QOS_Event_Handler () +{} + +ACE_QOS_Event_Handler::ACE_QOS_Event_Handler (const ACE_SOCK_Dgram_Mcast &dgram_mcast) +{ + this->dgram_mcast_ = dgram_mcast; +} // Destructor. -ACE_Read_Handler::~ACE_Read_Handler () -{}; +ACE_QOS_Event_Handler::~ACE_QOS_Event_Handler () +{ +} // Return the handle of the Dgram_Mcast. This method is // called internally by the reactor. ACE_HANDLE -ACE_Read_Handler::get_handle (void) const +ACE_QOS_Event_Handler::get_handle (void) const { return this->dgram_mcast_.get_handle (); } +int +ACE_QOS_Event_Handler::handle_qos (ACE_HANDLE) +{ + + ACE_DEBUG ((LM_DEBUG, + "\nReceived a QOS event. Inside handle_qos ()\n")); + + return 0; +} + // Called when there is a READ activity on the dgram_mcast handle. int -ACE_Read_Handler::handle_input (ACE_HANDLE) +ACE_QOS_Event_Handler::handle_input (ACE_HANDLE) { char buf[128]; @@ -65,9 +81,3 @@ ACE_Read_Handler::handle_input (ACE_HANDLE) return -1; } -// Set for a dgram_mcast; -void -ACE_Read_Handler::dgram_mcast (const ACE_SOCK_Dgram_Mcast &dgram_mcast) -{ - this->dgram_mcast_ = dgram_mcast; -} diff --git a/examples/QOS/Receiver_QOS_Event_Handler.h b/examples/QOS/Receiver_QOS_Event_Handler.h new file mode 100644 index 00000000000..6c9e76bfe81 --- /dev/null +++ b/examples/QOS/Receiver_QOS_Event_Handler.h @@ -0,0 +1,57 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// ACE_wrappers/examples/QOS +// +// = FILENAME +// Receiver_QOS_Event_Handler.h +// +// = AUTHOR +// Vishal Kachroo +// +// ============================================================================ + +#ifndef RECEIVER_QOS_EVENT_HANDLER_H +#define RECEIVER_QOS_EVENT_HANDLER_H + +#include "ace/Event_Handler.h" +#include "ace/Reactor.h" +#include "ace/INET_Addr.h" +#include "ace/SOCK_Dgram_Mcast.h" + +ACE_RCSID(Receiver_QOS_Event_Handler, Receiver_QOS_Event_Handler, "$Id$") + + class ACE_QOS_Event_Handler : public ACE_Event_Handler + { + public: + // = Initialization and Termination methods. + ACE_QOS_Event_Handler (void); + // Constructor. + + ACE_QOS_Event_Handler::ACE_QOS_Event_Handler (const ACE_SOCK_Dgram_Mcast &dgram_mcast); + // Constructor. + + ~ACE_QOS_Event_Handler (void); + // Destructor. + + virtual ACE_HANDLE get_handle (void) const; + // Override this to return the handle of the Dgram_Mcast + // that we are using. + + virtual int handle_qos (ACE_HANDLE fd); + // Handles a QOS event. Right now, just + // prints a message. + + virtual int handle_input (ACE_HANDLE fd); + // Handles a READ event. + + private: + + ACE_SOCK_Dgram_Mcast dgram_mcast_; + ACE_INET_Addr remote_addr_; + }; + +#endif /* RECEIVER_QOS_EVENT_HANDLER_H */ diff --git a/examples/QOS/Sender_QOS_Event_Handler.cpp b/examples/QOS/Sender_QOS_Event_Handler.cpp new file mode 100644 index 00000000000..8a3ca45f79e --- /dev/null +++ b/examples/QOS/Sender_QOS_Event_Handler.cpp @@ -0,0 +1,83 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// ACE_wrappers/examples/QOS +// +// = FILENAME +// Sender_QOS_Event_Handler.cpp +// +// = AUTHOR +// Vishal Kachroo +// +// ============================================================================ + +#include "Sender_QOS_Event_Handler.h" + +// Constructor. +ACE_QOS_Event_Handler::ACE_QOS_Event_Handler () +{} + +ACE_QOS_Event_Handler::ACE_QOS_Event_Handler (const ACE_SOCK_Dgram_Mcast &dgram_mcast) +{ + this->dgram_mcast_ = dgram_mcast; +} + +// Destructor. +ACE_QOS_Event_Handler::~ACE_QOS_Event_Handler () +{ +} + +// Return the handle of the Dgram_Mcast. This method is +// called internally by the reactor. + +ACE_HANDLE +ACE_QOS_Event_Handler::get_handle (void) const +{ + return this->dgram_mcast_.get_handle (); +} + +int +ACE_QOS_Event_Handler::handle_qos (ACE_HANDLE) +{ + + ACE_DEBUG ((LM_DEBUG, + "\nReceived a QOS event. Inside handle_qos ()\n")); + + WSAEVENT hevent = WSACreateEvent (); + ACE_OVERLAPPED ace_overlapped; + ace_overlapped.hEvent = hevent; + + SOCKADDR_IN sendto_addr; + ZeroMemory((PVOID)&sendto_addr, sizeof(sendto_addr)); + sendto_addr.sin_family = PF_INET; // protocol_info.iAddressFamily; + sendto_addr.sin_addr.s_addr = inet_addr("234.5.6.7"); // options.szHostname); + sendto_addr.sin_port = htons(5001); // options.port); + + const SOCKADDR_IN c_sendto_addr = sendto_addr; + + const iovec iov = {5,"Hello"}; + size_t bytes_sent; + + if (ACE_OS::sendto (this->dgram_mcast_.get_handle (), + &iov, + 1, + bytes_sent, + 0, + (const struct sockaddr *) &c_sendto_addr, + sizeof (c_sendto_addr), + &ace_overlapped, + NULL) != 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Error in Sendto\n"), + -1); + else + ACE_DEBUG ((LM_DEBUG, + "Using ACE_OS::sendto () : Bytes sent : %d", + bytes_sent)); + + return 0; +} + diff --git a/examples/QOS/QOS_Event_Handler.h b/examples/QOS/Sender_QOS_Event_Handler.h index c3915d6dbec..aa36b993dfb 100644 --- a/examples/QOS/QOS_Event_Handler.h +++ b/examples/QOS/Sender_QOS_Event_Handler.h @@ -4,7 +4,7 @@ // ============================================================================ // // = LIBRARY -// ACE_wrappers/examples/QOS/ +// ACE_wrappers/examples/ // // = FILENAME // QOS_Event_Handler.h @@ -14,13 +14,13 @@ // // ============================================================================ -#ifndef QOS_EVENT_HANDLER_H -#define QOS_EVENT_HANDLER_H +#ifndef SENDER_QOS_EVENT_HANDLER_H +#define SENDER_QOS_EVENT_HANDLER_H #include "ace/Event_Handler.h" #include "ace/Reactor.h" - -#include "Read_Handler.h" +#include "ace/INET_Addr.h" +#include "ace/SOCK_Dgram_Mcast.h" ACE_RCSID(QOS_Event_Handler, QOS_Event_Handler, "$Id$") @@ -43,12 +43,12 @@ ACE_RCSID(QOS_Event_Handler, QOS_Event_Handler, "$Id$") virtual int handle_qos (ACE_HANDLE fd); // Handles a QOS event. Right now, just - // registers a handler for the READ events. + // prints a message. private: - ACE_Read_Handler read_handler_; - + ACE_SOCK_Dgram_Mcast dgram_mcast_; + ACE_INET_Addr remote_addr_; }; -#endif /* QOS_EVENT_HANDLER_H */ +#endif /* SENDER_QOS_EVENT_HANDLER_H */ diff --git a/examples/QOS/client.cpp b/examples/QOS/client.cpp index 642e670dd7c..1d28b16fe2e 100644 --- a/examples/QOS/client.cpp +++ b/examples/QOS/client.cpp @@ -5,6 +5,7 @@ #define QOSEVENT_MAIN #include "qosevent.h" +#include "Sender_QOS_Event_Handler.h" static u_short SERVER_PORT = MY_DEFPORT; static const char *const SERVER_HOST = DEFAULT_MULTICASTGROUP; @@ -80,7 +81,6 @@ fill_ace_qos_flowspec_default (ACE_QoS *pQos, 1 // Priority. ACE specific. Not used on NT. ); - ACE_Flow_Spec ace_default_notraffic (QOS_NOT_SPECIFIED, QOS_NOT_SPECIFIED, QOS_NOT_SPECIFIED, @@ -266,14 +266,16 @@ main (int argc, char * argv[]) ACE_SOCK_Dgram_Mcast dgram_mcast; + // It is absolutely necessary that the sender and the receiver subscribe + // to the same multicast addresses to make sure the "multicast sessions" + // for the two are the same. This is used to match the RESV<->PATH states. + SOCKADDR_IN addr; ZeroMemory((PVOID)&addr, sizeof(addr)); addr.sin_family = PF_INET; //protocol_info.iAddressFamily; addr.sin_addr.s_addr = inet_addr("234.5.6.7"); //options.szHostname); - - // PORT changed as opposed to the receiver. - addr.sin_port = htons(5002); //options.port); + addr.sin_port = htons(5001); //options.port); ACE_INET_Addr mult_addr (&addr, sizeof (addr)); @@ -363,37 +365,23 @@ main (int argc, char * argv[]) ACE_DEBUG ((LM_DEBUG, "Setting Default QOS with ACE_OS::ioctl succeeds \n")); - WSAEVENT hevent = WSACreateEvent (); - ACE_OVERLAPPED ace_overlapped; - ace_overlapped.hEvent = hevent; - - SOCKADDR_IN sendto_addr; - ZeroMemory((PVOID)&sendto_addr, sizeof(sendto_addr)); - sendto_addr.sin_family = PF_INET; // protocol_info.iAddressFamily; - sendto_addr.sin_addr.s_addr = inet_addr("234.5.6.7"); // options.szHostname); - sendto_addr.sin_port = htons(5001); // options.port); - - const SOCKADDR_IN c_sendto_addr = sendto_addr; - - const iovec iov = {5,"Hello"}; - size_t bytes_sent; - - if (ACE_OS::sendto (dgram_mcast.get_handle (), - &iov, - 1, - bytes_sent, - 0, - (const struct sockaddr *) &c_sendto_addr, - sizeof (c_sendto_addr), - &ace_overlapped, - NULL) != 0) + // Instantiate a QOS Event Handler and pass the Dgram_Mcast into it. + ACE_QOS_Event_Handler qos_event_handler (dgram_mcast); + + // Register the QOS Handler with the Reactor for the QOS_MASK. + // Note the receiver registers for both QOS_MASK as well as READ_MASK. + + if (ACE_Reactor::instance ()->register_handler (&qos_event_handler, + ACE_Event_Handler::QOS_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, - "Error in Sendto\n"), + "Error in registering QOS Handler\n"), -1); - else - ACE_DEBUG ((LM_DEBUG, - "SendTO : Bytes sent : %d", - bytes_sent)); + + // Start the event loop. + ACE_DEBUG ((LM_DEBUG, + "Running the Event Loop ... \n")); + + ACE_Reactor::instance ()->run_event_loop (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) shutting down Sender\n")); |