1//
2// SecureServerSocket.h
3//
4// Library: NetSSL_OpenSSL
5// Package: SSLSockets
6// Module: SecureServerSocket
7//
8// Definition of the SecureServerSocket 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_SecureServerSocket_INCLUDED
18#define NetSSL_SecureServerSocket_INCLUDED
19
20
21#include "Poco/Net/NetSSL.h"
22#include "Poco/Net/ServerSocket.h"
23#include "Poco/Net/Context.h"
24
25
26namespace Poco {
27namespace Net {
28
29
30class NetSSL_API SecureServerSocket: public ServerSocket
31 /// A server socket for secure SSL connections.
32{
33public:
34 SecureServerSocket();
35 /// Creates a SSL server socket using the
36 /// default SSL server context.
37 ///
38 /// The server socket must be bound to
39 /// an address and put into listening state.
40
41 explicit SecureServerSocket(Context::Ptr pContext);
42 /// Creates a SSL server socket, using the
43 /// given SSL context object.
44 ///
45 /// The server socket must be bound to
46 /// an address and put into listening state.
47
48 SecureServerSocket(const Socket& socket);
49 /// Creates the SecureServerSocket with the SocketImpl
50 /// from another socket. The SocketImpl must be
51 /// a SecureServerSocketImpl, otherwise an InvalidArgumentException
52 /// will be thrown.
53
54 SecureServerSocket(const SocketAddress& address, int backlog = 64);
55 /// Creates a server socket using the default server SSL context,
56 /// binds it to the given address and puts it in listening
57 /// state.
58 ///
59 /// After successful construction, the server socket
60 /// is ready to accept connections.
61
62 SecureServerSocket(const SocketAddress& address, int backlog, Context::Ptr pContext);
63 /// Creates a server socket using the given SSL context, binds it
64 /// to the given address and puts it in listening
65 /// state.
66 ///
67 /// After successful construction, the server socket
68 /// is ready to accept connections.
69
70 SecureServerSocket(Poco::UInt16 port, int backlog = 64);
71 /// Creates a server socket using the default server SSL context,
72 /// binds it to the given port and puts it in listening
73 /// state.
74 ///
75 /// After successful construction, the server socket
76 /// is ready to accept connections.
77
78 SecureServerSocket(Poco::UInt16 port, int backlog, Context::Ptr pContext);
79 /// Creates a server socket using the given SSL context, binds it
80 /// to the given port and puts it in listening
81 /// state.
82 ///
83 /// After successful construction, the server socket
84 /// is ready to accept connections.
85
86 virtual ~SecureServerSocket();
87 /// Destroys the StreamSocket.
88
89 SecureServerSocket& operator = (const Socket& socket);
90 /// Assignment operator.
91 ///
92 /// Releases the socket's SocketImpl and
93 /// attaches the SocketImpl from the other socket and
94 /// increments the reference count of the SocketImpl.
95
96 StreamSocket acceptConnection(SocketAddress& clientAddr);
97 /// Get the next completed connection from the
98 /// socket's completed connection queue.
99 ///
100 /// If the queue is empty, waits until a connection
101 /// request completes.
102 ///
103 /// Returns a new SSL socket for the connection
104 /// with the client.
105 ///
106 /// The client socket's address is returned in clientAddr.
107 ///
108 /// No SSL handshake is performed on the new connection.
109 /// The SSL handshake will be performed the first time
110 /// sendBytes(), receiveBytes() or completeHandshake()
111 /// is called on the returned SecureStreamSocket.
112
113 StreamSocket acceptConnection();
114 /// Get the next completed connection from the
115 /// socket's completed connection queue.
116 ///
117 /// If the queue is empty, waits until a connection
118 /// request completes.
119 ///
120 /// Returns a new SSL socket for the connection
121 /// with the client.
122 ///
123 /// No SSL handshake is performed on the new connection.
124 /// The SSL handshake will be performed the first time
125 /// sendBytes(), receiveBytes() or completeHandshake()
126 /// is called on the returned SecureStreamSocket.
127
128 Context::Ptr context() const;
129 /// Returns the SSL context used by this socket.
130};
131
132
133} } // namespace Poco::Net
134
135
136#endif // NetSSL_SecureServerSocket_INCLUDED
137