SecureServerSocket.h 4.0 KB

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