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
27namespace Poco {
28namespace Net {
29
30
31class NetSSL_API SecureServerSocketImpl: public ServerSocketImpl
32 /// The SocketImpl class for SecureServerSocket.
33{
34public:
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 bind6(const SocketAddress& address, bool reuseAddress = false, bool ipV6Only = false);
77 /// Bind a local IPv6 address to the socket.
78 ///
79 /// This is usually only done when establishing a server
80 /// socket. TCP clients should not bind a socket to a
81 /// specific address.
82 ///
83 /// If reuseAddress is true, sets the SO_REUSEADDR
84 /// socket option.
85 ///
86 /// The given address must be an IPv6 address. The
87 /// IPPROTO_IPV6/IPV6_V6ONLY option is set on the socket
88 /// according to the ipV6Only parameter.
89 ///
90 /// If the library has not been built with IPv6 support,
91 /// a Poco::NotImplementedException will be thrown.
92
93 void listen(int backlog = 64);
94 /// Puts the socket into listening state.
95 ///
96 /// The socket becomes a passive socket that
97 /// can accept incoming connection requests.
98 ///
99 /// The backlog argument specifies the maximum
100 /// number of connections that can be queued
101 /// for this socket.
102
103 void close();
104 /// Close the socket.
105
106 int sendBytes(const void* buffer, int length, int flags = 0);
107 /// Not supported by this kind of socket.
108 ///
109 /// Throws a Poco::InvalidAccessException.
110
111 int receiveBytes(void* buffer, int length, int flags = 0);
112 /// Not supported by this kind of socket.
113 ///
114 /// Throws a Poco::InvalidAccessException.
115
116 int sendTo(const void* buffer, int length, const SocketAddress& address, int flags = 0);
117 /// Not supported by this kind of socket.
118 ///
119 /// Throws a Poco::InvalidAccessException.
120
121 int receiveFrom(void* buffer, int length, SocketAddress& address, int flags = 0);
122 /// Not supported by this kind of socket.
123 ///
124 /// Throws a Poco::InvalidAccessException.
125
126 void sendUrgent(unsigned char data);
127 /// Not supported by this kind of socket.
128 ///
129 /// Throws a Poco::InvalidAccessException.
130
131 bool secure() const;
132 /// Returns true iff the socket's connection is secure
133 /// (using SSL or TLS).
134
135 Context::Ptr context() const;
136 /// Returns the SSL context used by this socket.
137
138protected:
139 ~SecureServerSocketImpl();
140 /// Destroys the SecureServerSocketImpl.
141
142private:
143 SecureServerSocketImpl(const SecureServerSocketImpl&);
144 SecureServerSocketImpl& operator = (const SecureServerSocketImpl&);
145
146private:
147 SecureSocketImpl _impl;
148};
149
150
151//
152// inlines
153//
154inline Context::Ptr SecureServerSocketImpl::context() const
155{
156 return _impl.context();
157}
158
159
160} } // namespace Poco::Net
161
162
163#endif // NetSSL_SecureServerSocketImpl_INCLUDED
164