Document return values
[ACE_TAO.git] / ACE / ace / SSL / SSL_SOCK_Acceptor.h
blob0cbfa232c28f089c7fc53f4dcbf3c3724282016b
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file SSL_SOCK_Acceptor.h
7 * @author John Heitmann
8 * @author Chris Zimman
9 * @author Ossama Othman <ossama@uci.edu>
11 //=============================================================================
13 #ifndef ACE_SSL_SOCK_ACCEPTOR_H
14 #define ACE_SSL_SOCK_ACCEPTOR_H
16 #include /**/ "ace/pre.h"
18 #include "SSL_Export.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "SSL_SOCK_Stream.h"
26 #include "ace/SOCK_Acceptor.h"
27 #include "ace/OS_QoS.h"
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 /**
32 * @class ACE_SSL_SOCK_Acceptor
34 * @brief Defines a factory that creates new @c ACE_SSL_SOCK_Stream
35 * objects passively.
37 * The ACE_SSL_SOCK_Acceptor has its own @c ACE_SOCK_Acceptor
38 * which handles the basic socket acceptance. This class is a
39 * wrapper which adds the SSL acceptance handshake handling.
40 * Since SSL is record oriented, some additional steps must be taken
41 * after the basic socket acceptance to complete the SSL handshake that
42 * takes place at session establishment.
44 * @note The user must currently ensure that only one thread services
45 * a given SSL session at any given time since some underlying
46 * SSL implementations, such as OpenSSL, are not entirely
47 * thread-safe or reentrant.
49 class ACE_SSL_Export ACE_SSL_SOCK_Acceptor : public ACE_SSL_SOCK
51 public:
52 /// Default constructor.
53 ACE_SSL_SOCK_Acceptor ();
55 /// Default destructor.
56 ~ACE_SSL_SOCK_Acceptor ();
58 /**
59 * Initiate a passive mode SSL/BSD-style acceptor socket.
60 * @param local_sap The address that we're going to listen for
61 * connections on. If this is @c ACE_Addr::sap_any,
62 * this socket listens on an the "any" IP address
63 * and selects an unused port. To find out what port
64 * was selected, call this object's
65 * @c ACE_SOCK::get_local_addr(ACE_Addr&) method
66 * upon return.
68 ACE_SSL_SOCK_Acceptor (const ACE_Addr &local_sap,
69 int reuse_addr = 0,
70 int protocol_family = PF_UNSPEC,
71 int backlog = ACE_DEFAULT_BACKLOG,
72 int protocol = 0,
73 int ipv6_only = 0);
75 /**
76 * Initiate a passive-mode QoS-enabled acceptor socket.
77 * @param local_sap The address that we're going to listen for
78 * connections on. If this is @c ACE_Addr::sap_any,
79 * this socket listens on an the "any" IP address
80 * and selects an unused port. To find out what port
81 * was selected, call this object's
82 * @c ACE_SOCK::get_local_addr(ACE_Addr&) method
83 * upon return.
85 ACE_SSL_SOCK_Acceptor (const ACE_Addr &local_sap,
86 ACE_Protocol_Info *protocolinfo,
87 ACE_SOCK_GROUP g,
88 u_long flags,
89 int reuse_addr,
90 int protocol_family = PF_UNSPEC,
91 int backlog = ACE_DEFAULT_BACKLOG,
92 int protocol = 0,
93 int ipv6_only = 0);
95 /**
96 * Initiate a passive mode SSL/BSD-style acceptor socket.
97 * @param local_sap The address that we're going to listen for
98 * connections on. If this is @c ACE_Addr::sap_any,
99 * this socket listens on an the "any" IP address
100 * and selects an unused port. To find out what port
101 * was selected, call this object's
102 * @c ACE_SOCK::get_local_addr(ACE_Addr&) method
103 * upon return.
105 * @return 0 if success; -1 for failure (errno contains error code).
107 int open (const ACE_Addr &local_sap,
108 int reuse_addr = 0,
109 int protocol_family = PF_UNSPEC,
110 int backlog = ACE_DEFAULT_BACKLOG,
111 int protocol = 0,
112 int ipv6_only = 0);
114 /// Close the listening socket.
115 int close ();
118 * @name Passive Connection "accept" Methods
120 * These are the canonical methods exposed by the Acceptor pattern.
122 //@{
124 * Accept a new ACE_SSL_SOCK_Stream connection. On successful return,
125 * the socket has been accepted and the SSL handshake has been completed.
126 * @param new_stream The @c ACE_SSL_SOCK_Stream object that will receive
127 * the new SSL socket.
128 * @param remote_addr Pointer to an @c ACE_INET_Addr object that will
129 * receive the address of the peer that connected.
130 * @param timeout The maximum time to wait for the combined socket
131 * acceptance and handshake completion. 0 means
132 * block forever, a timeout of {0, 0} means poll.
133 * @param restart 1 means "restart if interrupted," that is,
134 * if errno == EINTR.
136 * @return 0 if success; -1 for failure (errno contains error code).
138 int accept (ACE_SSL_SOCK_Stream &new_stream,
139 ACE_Addr *remote_addr = 0,
140 ACE_Time_Value *timeout = 0,
141 bool restart = true,
142 bool reset_new_handle = false) const;
145 * Accept a new ACE_SSL_SOCK_Stream connection using the RVSP QoS
146 * information in qos_params.
147 * @param new_stream The @c ACE_SSL_SOCK_Stream object that will receive
148 * the new SSL socket.
149 * @param remote_addr Pointer to an @c ACE_INET_Addr object that will
150 * receive the address of the peer that connected.
151 * @param timeout The maximum time to wait for the combined socket
152 * acceptance and handshake completion. 0 means
153 * block forever, a timeout of {0, 0} means poll.
154 * @param restart 1 means "restart if interrupted," that is,
155 * if errno == EINTR.
157 * @return 0 if success; -1 for failure (errno contains error code).
159 int accept (ACE_SSL_SOCK_Stream &new_stream,
160 ACE_Accept_QoS_Params qos_params,
161 ACE_Addr *remote_addr = 0,
162 ACE_Time_Value *timeout = 0,
163 bool restart = true,
164 bool reset_new_handle = false) const;
165 //@}
167 /// Meta-type info
168 //@{
169 typedef ACE_INET_Addr PEER_ADDR;
170 typedef ACE_SSL_SOCK_Stream PEER_STREAM;
171 //@}
173 /// Declare the dynamic allocation hooks.
174 ACE_ALLOC_HOOK_DECLARE;
176 protected:
177 /// Complete SSL passive connection establishment.
178 int ssl_accept (ACE_SSL_SOCK_Stream &new_stream,
179 ACE_Time_Value *timeout) const;
181 private:
182 /// The BSD-socket workhorse
183 ACE_SOCK_Acceptor acceptor_;
186 ACE_END_VERSIONED_NAMESPACE_DECL
188 #if defined (__ACE_INLINE__)
189 #include "SSL_SOCK_Acceptor.inl"
190 #endif /* __ACE_INLINE__ */
192 #include /**/ "ace/post.h"
194 #endif /* ACE_SSL_SOCK_ACCEPTOR_H */