1 | // |
2 | // SecureServerSocketImpl.h |
3 | // |
4 | // Library: NetSSL_OpenSSL |
5 | // Package: SSLSockets |
6 | // Module: SecureServerSocketImpl |
7 | // |
8 | // Definition of the SecureServerSocketImpl class. |
9 | // |
10 | // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #ifndef NetSSL_SecureServerSocketImpl_INCLUDED |
18 | #define NetSSL_SecureServerSocketImpl_INCLUDED |
19 | |
20 | |
21 | #include "Poco/Net/NetSSL.h" |
22 | #include "Poco/Net/SecureSocketImpl.h" |
23 | #include "Poco/Net/ServerSocketImpl.h" |
24 | #include "Poco/Net/Context.h" |
25 | |
26 | |
27 | namespace Poco { |
28 | namespace Net { |
29 | |
30 | |
31 | class NetSSL_API SecureServerSocketImpl: public ServerSocketImpl |
32 | /// The SocketImpl class for SecureServerSocket. |
33 | { |
34 | public: |
35 | SecureServerSocketImpl(Context::Ptr pContext); |
36 | /// Creates the SecureServerSocketImpl using the |
37 | /// given SSL context object. |
38 | |
39 | SocketImpl* acceptConnection(SocketAddress& clientAddr); |
40 | /// Get the next completed connection from the |
41 | /// socket's completed connection queue. |
42 | /// |
43 | /// If the queue is empty, waits until a connection |
44 | /// request completes. |
45 | /// |
46 | /// Returns a new TCP socket for the connection |
47 | /// with the client. |
48 | /// |
49 | /// The client socket's address is returned in clientAddr. |
50 | |
51 | void connect(const SocketAddress& address); |
52 | /// Not supported by this kind of socket. |
53 | /// |
54 | /// Throws a Poco::InvalidAccessException. |
55 | |
56 | void connect(const SocketAddress& address, const Poco::Timespan& timeout); |
57 | /// Not supported by this kind of socket. |
58 | /// |
59 | /// Throws a Poco::InvalidAccessException. |
60 | |
61 | void connectNB(const SocketAddress& address); |
62 | /// Not supported by this kind of socket. |
63 | /// |
64 | /// Throws a Poco::InvalidAccessException. |
65 | |
66 | void bind(const SocketAddress& address, bool reuseAddress = false, bool reusePort = false); |
67 | /// Bind a local address to the socket. |
68 | /// |
69 | /// This is usually only done when establishing a server |
70 | /// socket. TCP clients should not bind a socket to a |
71 | /// specific address. |
72 | /// |
73 | /// If reuseAddress is true, sets the SO_REUSEADDR |
74 | /// socket option. |
75 | |
76 | void listen(int backlog = 64); |
77 | /// Puts the socket into listening state. |
78 | /// |
79 | /// The socket becomes a passive socket that |
80 | /// can accept incoming connection requests. |
81 | /// |
82 | /// The backlog argument specifies the maximum |
83 | /// number of connections that can be queued |
84 | /// for this socket. |
85 | |
86 | void close(); |
87 | /// Close the socket. |
88 | |
89 | int sendBytes(const void* buffer, int length, int flags = 0); |
90 | /// Not supported by this kind of socket. |
91 | /// |
92 | /// Throws a Poco::InvalidAccessException. |
93 | |
94 | int receiveBytes(void* buffer, int length, int flags = 0); |
95 | /// Not supported by this kind of socket. |
96 | /// |
97 | /// Throws a Poco::InvalidAccessException. |
98 | |
99 | int sendTo(const void* buffer, int length, const SocketAddress& address, int flags = 0); |
100 | /// Not supported by this kind of socket. |
101 | /// |
102 | /// Throws a Poco::InvalidAccessException. |
103 | |
104 | int receiveFrom(void* buffer, int length, SocketAddress& address, int flags = 0); |
105 | /// Not supported by this kind of socket. |
106 | /// |
107 | /// Throws a Poco::InvalidAccessException. |
108 | |
109 | void sendUrgent(unsigned char data); |
110 | /// Not supported by this kind of socket. |
111 | /// |
112 | /// Throws a Poco::InvalidAccessException. |
113 | |
114 | bool secure() const; |
115 | /// Returns true iff the socket's connection is secure |
116 | /// (using SSL or TLS). |
117 | |
118 | Context::Ptr context() const; |
119 | /// Returns the SSL context used by this socket. |
120 | |
121 | protected: |
122 | ~SecureServerSocketImpl(); |
123 | /// Destroys the SecureServerSocketImpl. |
124 | |
125 | private: |
126 | SecureServerSocketImpl(const SecureServerSocketImpl&); |
127 | SecureServerSocketImpl& operator = (const SecureServerSocketImpl&); |
128 | |
129 | private: |
130 | SecureSocketImpl _impl; |
131 | }; |
132 | |
133 | |
134 | // |
135 | // inlines |
136 | // |
137 | inline Context::Ptr SecureServerSocketImpl::context() const |
138 | { |
139 | return _impl.context(); |
140 | } |
141 | |
142 | |
143 | } } // namespace Poco::Net |
144 | |
145 | |
146 | #endif // NetSSL_SecureServerSocketImpl_INCLUDED |
147 | |