Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / JAWS2 / JAWS / IO_Acceptor.h
blobbf92cf3d2d79ccfa75a94e2d4dd6392f3645b38e
1 /* -*- c++ -*- */
2 #ifndef JAWS_IO_ACCEPTOR_H
3 #define JAWS_IO_ACCEPTOR_H
5 // Use the Adapter pattern to encapsulate either a LOCK_SOCK_Acceptor or
6 // an ACE_Asynch_Acceptor
8 #include "ace/Asynch_Acceptor.h"
10 #if !defined (ACE_LACKS_PRAGMA_ONCE)
11 # pragma once
12 #endif /* ACE_LACKS_PRAGMA_ONCE */
14 #include "ace/LOCK_SOCK_Acceptor.h"
15 #include "ace/Singleton.h"
17 #include "JAWS/Export.h"
18 #include "JAWS/Jaws_IO.h"
19 #include "JAWS/IO_Handler.h"
21 // Forward declaration.
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
23 class ACE_Proactor;
24 class ACE_Reactor;
25 ACE_END_VERSIONED_NAMESPACE_DECL
27 #if defined (JAWS_HAS_THREAD_SAFE_ACCEPT)
28 typedef ACE_LOCK_SOCK_Acceptor<ACE_SYNCH_NULL_MUTEX> JAWS_IO_SOCK_Acceptor;
29 #else
30 typedef ACE_LOCK_SOCK_Acceptor<ACE_SYNCH_MUTEX> JAWS_IO_SOCK_Acceptor;
31 #endif /* JAWS_HAS_THREAD_SAFE_ACCEPT */
33 class JAWS_Export JAWS_IO_Acceptor
35 public:
36 JAWS_IO_Acceptor ();
37 virtual ~JAWS_IO_Acceptor ();
39 virtual int open (const ACE_INET_Addr &address, int backlog = 20);
40 // Initiate a passive mode socket.
42 virtual int open (const ACE_HANDLE &socket);
43 // Initiate a passive mode socket.
45 virtual int accept (ACE_SOCK_Stream &new_stream,
46 ACE_Addr *remote_addr = 0,
47 ACE_Time_Value *timeout = 0,
48 int restart = 1,
49 int reset_new_handle = 0) const;
50 // Synchronously accept the connection
52 virtual int accept (size_t bytes_to_read = 0, const void *act = 0);
53 // This initiates a new asynchronous accept through the AcceptEx call.
55 virtual ACE_HANDLE get_handle ();
56 // Get the listener's handle
58 virtual void close ();
59 // Close the acceptor.
61 enum { ASYNC = 0, SYNCH = 1 };
62 // identify if this is being used for asynchronous or synchronous
63 // accept calls
66 class JAWS_Export JAWS_IO_Synch_Acceptor : public JAWS_IO_Acceptor
68 public:
69 virtual int open (const ACE_INET_Addr &local_sap, int backlog = 20);
70 // Initiate a passive mode socket.
72 virtual int open (const ACE_HANDLE &socket);
73 // Initiate a passive mode socket.
75 virtual int accept (ACE_SOCK_Stream &new_stream,
76 ACE_Addr *remote_addr = 0,
77 ACE_Time_Value *timeout = 0,
78 int restart = 1,
79 int reset_new_handle = 0) const;
80 // Accept the connection
82 virtual ACE_HANDLE get_handle ();
83 // Get the listener's handle
85 private:
86 virtual int accept (size_t bytes_to_read = 0, const void *act = 0);
88 private:
89 JAWS_IO_SOCK_Acceptor acceptor_;
93 class JAWS_Export JAWS_IO_Asynch_Acceptor : public JAWS_IO_Acceptor
95 public:
96 JAWS_IO_Asynch_Acceptor ();
97 virtual ~JAWS_IO_Asynch_Acceptor ();
99 virtual int open (const ACE_INET_Addr &address, int backlog = 20);
100 // Initiate an asynchronous passive connection
102 virtual int open (const ACE_HANDLE &socket);
103 // Initiate an asynchronous passive connection
105 virtual int accept (size_t bytes_to_read = 0, const void *act = 0);
106 // This initiates a new asynchronous accept through the AcceptEx call.
108 virtual ACE_HANDLE get_handle ();
109 // Get the listener's handle
111 virtual void close ();
113 private:
114 virtual int accept (ACE_SOCK_Stream &new_stream,
115 ACE_Addr *remote_addr = 0,
116 ACE_Time_Value *timeout = 0,
117 int restart = 1,
118 int reset_new_handle = 0) const;
120 private:
121 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
122 ACE_Asynch_Acceptor<JAWS_Asynch_Handler> &acceptor_;
123 ACE_Asynch_Acceptor<JAWS_Asynch_Handler> *acceptor_ptr_;
124 ACE_HANDLE handle_;
125 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
128 typedef ACE_Singleton<JAWS_IO_Synch_Acceptor, ACE_SYNCH_MUTEX>
129 JAWS_IO_Synch_Acceptor_Singleton;
131 typedef ACE_Singleton<JAWS_IO_Asynch_Acceptor, ACE_SYNCH_MUTEX>
132 JAWS_IO_Asynch_Acceptor_Singleton;
134 #endif /* !defined (JAWS_IO_ACCEPTOR_H) */