diff options
author | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-09 22:39:47 +0000 |
---|---|---|
committer | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-04-09 22:39:47 +0000 |
commit | c8546efd0ed82825c416762d78612a2270d3e3a0 (patch) | |
tree | 6d237f2fb5a0a3cd35b4d214d5e0c09d8c55aabc /apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h | |
parent | c8a6db32b186cc5c45b1e4e3e9a9e56d3b43ff4f (diff) | |
download | ATCD-c8546efd0ed82825c416762d78612a2270d3e3a0.tar.gz |
INitial add
Diffstat (limited to 'apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h')
-rw-r--r-- | apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h b/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h new file mode 100644 index 00000000000..36b7b4fabb0 --- /dev/null +++ b/apps/JAWS/PROTOTYPE/JAWS/IO_Acceptor.h @@ -0,0 +1,99 @@ +/* -*- c++ -*- */ +// $Id$ + +#if !defined (JAWS_IO_ACCEPTOR_H) +#define JAWS_IO_ACCEPTOR_H + +// Use the Adapter pattern to encapsulate either a LOCK_SOCK_Acceptor or +// an ACE_Asynch_Acceptor + +#include "ace/Asynch_Acceptor.h" +#include "ace/LOCK_SOCK_Acceptor.h" +#include "ace/Singleton.h" + +#include "JAWS/IO.h" + +// Forward declaration. +class ACE_Proactor; +class ACE_Reactor; + +#if defined (ACE_HAS_THREAD_SAFE_ACCEPT) +typedef ACE_LOCK_SOCK_Acceptor<ACE_SYNCH_NULL_MUTEX> JAWS_IO_SOCK_Acceptor; +#else +typedef ACE_LOCK_SOCK_Acceptor<ACE_SYNCH_MUTEX> JAWS_IO_SOCK_Acceptor; +#endif /* ACE_HAS_THREAD_SAFE_ACCEPT */ + +class JAWS_IO_Acceptor +{ +public: + + JAWS_IO_Acceptor (void); + virtual ~JAWS_IO_Acceptor (void); + + virtual int open (const ACE_INET_Addr &address); + // Initiate a passive mode socket. + + virtual int accept (ACE_SOCK_Stream &new_stream, + ACE_Addr *remote_addr = 0, + ACE_Time_Value *timeout = 0, + int restart = 1, + int reset_new_handle = 0) const; + // Synchronously accept the connection + + virtual int accept (size_t bytes_to_read = 0); + // This initiates a new asynchronous accept through the AcceptEx call. + + enum { ASYNC = 0, SYNCH = 1 }; + // identify if this is being used for aynchronous or synchronous + // accept calls + +private: + +}; + +class JAWS_IO_Synch_Acceptor : public JAWS_IO_Acceptor +{ +public: + + virtual int open (const ACE_INET_Addr &local_sap); + // Initiate a passive mode socket. + + virtual int accept (ACE_SOCK_Stream &new_stream, + ACE_Addr *remote_addr = 0, + ACE_Time_Value *timeout = 0, + int restart = 1, + int reset_new_handle = 0) const; + // Accept the connection + +private: + JAWS_IO_SOCK_Acceptor *acceptor_; +}; + + +class JAWS_IO_Asynch_Acceptor : public JAWS_IO_Acceptor +{ +public: + + virtual int open (const ACE_INET_Addr &address); + // Initiate an asynchronous passive connection + + virtual int accept (size_t bytes_to_read = 0); + // This initiates a new asynchronous accept through the AcceptEx call. + +private: + +#if defined (ACE_WIN32) +// This only works on Win32 platforms + ACE_Asynch_Acceptor<JAWS_IO_Handler> *acceptor_; +#else + void *acceptor_; +#endif /* defined (ACE_WIN32) */ +}; + +typedef ACE_Singleton<JAWS_IO_Synch_Acceptor, ACE_SYNCH_MUTEX> + JAWS_IO_Synch_Acceptor_Singleton; + +typedef ACE_Singleton<JAWS_IO_Asynch_Acceptor, ACE_SYNCH_MUTEX> + JAWS_IO_Asynch_Acceptor_Singleton; + +#endif /* !defined (JAWS_IO_ACCEPTOR_H) */ |