diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-04-07 15:15:30 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-04-07 15:15:30 +0000 |
commit | bba0a877208338c9d9d6ba5034d54071be0376ee (patch) | |
tree | 341a30609e2e2c5b4b2abb3bbaf2e375bbc9bb59 /ace/Asynch_Acceptor.h | |
parent | 6f17a44988bf74e0f5550e3ab044b91f5d9ed7e4 (diff) | |
download | ATCD-bba0a877208338c9d9d6ba5034d54071be0376ee.tar.gz |
added Asynch_Acceptor.{h,cpp} and Asynch_IO.{h,cpp}
Diffstat (limited to 'ace/Asynch_Acceptor.h')
-rw-r--r-- | ace/Asynch_Acceptor.h | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/ace/Asynch_Acceptor.h b/ace/Asynch_Acceptor.h new file mode 100644 index 00000000000..99347e7df4d --- /dev/null +++ b/ace/Asynch_Acceptor.h @@ -0,0 +1,123 @@ +/* -*- C++ -*- */ +// $Id: Asynch_Acceptor.h,v + +// ============================================================================ +// +// = LIBRARY +// ace +// +// = FILENAME +// Asynch_Acceptor.h +// +// = AUTHOR +// Irfan Pyarali (irfan@cs.wustl.edu) +// +// ============================================================================ + +#if !defined (ACE_ASYNCH_ACCEPTOR_H) +#define ACE_ASYNCH_ACCEPTOR_H + +#include "ace/OS.h" + +#if defined (ACE_WIN32) +// This only works on Win32 platforms + +#include "ace/Asynch_IO.h" + +// Forward declarations +class ACE_Message_Block; +class ACE_INET_Addr; + +template <class HANDLER> +class ACE_Asynch_Acceptor : public ACE_Handler + // + // = TITLE + // + // This class is an example of the Acceptor Pattern. This class + // will accept new connections and create new HANDLER to handle + // the new connections. + // + // = DESCRIPTION + // +{ +public: + ACE_Asynch_Acceptor (void); + // A do nothing constructor. + + ~ACE_Asynch_Acceptor (void); + // Virtual destruction + + int open (const ACE_INET_Addr &address, + size_t bytes_to_read = 0, + int pass_addresses = 0, + int backlog = 5, + int reuse_addr = 1); + // This starts the listening process at the port specified by + // <address>. ACE_Asynch_Acceptor initiates the AcceptEx calls with + // <bytes_to_read>. The buffer for the initial data will be created + // by ACE_Asynch_Acceptor. This buffer will be passed to the + // handler in the <ACE_Service_Handler::open> callback. If this + // buffer is required past the <open> callback, the + // ACE_Service_Handler must copy the data. If the <pass_addresses> + // flag is set, ACE_Asynch_Acceptor will call + // <ACE_Service_Handler::addresses> before calling + // <ACE_Service_Handler::open>. The <backlog> parameter specifies + // the listen backlog and the outstanding AcceptEx calls. + + int accept (size_t bytes_to_read = 0); + // This initiates a new asynchronous accept through the AcceptEx call. + + static size_t address_size (void); + // This is required by the AcceptEx call. + + int cancel (void); + // This cancels all pending accepts operations that were issued by + // the calling thread. The function does not cancel accept + // operations issued by other threads. + +protected: + virtual void handle_accept (const ACE_Asynch_Accept::Result &result); + // This is called when an outstanding accept completes. + + ACE_HANDLE handle (void) const; + // Return the listen handle. + + void parse_address (ACE_Message_Block &message_block, + ACE_INET_Addr &remote_address, + ACE_INET_Addr &local_address); + // This parses the address from read buffer. + + virtual HANDLER *make_handler (void); + // This is the template method used to create new handler. + // Subclasses must overwrite this method if a new handler creation + // strategy is required. + +private: + ACE_HANDLE listen_handle_; + // Handle used to listen for new connections. + + ACE_Asynch_Accept asynch_accept_; + // Asynch_Accept used to make life easier :-) + + int pass_addresses_; + // Flag that indicates if parsing of addresses is necessary. + + int bytes_to_read_; + // Bytes to be read with the accept call. +}; + +#if defined (__ACE_INLINE__) +#include "ace/Asynch_Acceptor.i" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Asynch_Acceptor.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Asynch_Acceptor.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_WIN32 */ +#endif /* ACE_ASYNCH_ACCEPTOR_H */ + |