SecureServerSocketImpl.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #ifndef NetSSL_SecureServerSocketImpl_INCLUDED
  16. #define NetSSL_SecureServerSocketImpl_INCLUDED
  17. #include "Poco/Net/NetSSL.h"
  18. #include "Poco/Net/SecureSocketImpl.h"
  19. #include "Poco/Net/ServerSocketImpl.h"
  20. #include "Poco/Net/Context.h"
  21. namespace Poco {
  22. namespace Net {
  23. class NetSSL_API SecureServerSocketImpl: public ServerSocketImpl
  24. /// The SocketImpl class for SecureServerSocket.
  25. {
  26. public:
  27. SecureServerSocketImpl(Context::Ptr pContext);
  28. /// Creates the SecureServerSocketImpl using the
  29. /// given SSL context object.
  30. SocketImpl* acceptConnection(SocketAddress& clientAddr);
  31. /// Get the next completed connection from the
  32. /// socket's completed connection queue.
  33. ///
  34. /// If the queue is empty, waits until a connection
  35. /// request completes.
  36. ///
  37. /// Returns a new TCP socket for the connection
  38. /// with the client.
  39. ///
  40. /// The client socket's address is returned in clientAddr.
  41. void connect(const SocketAddress& address);
  42. /// Not supported by this kind of socket.
  43. ///
  44. /// Throws a Poco::InvalidAccessException.
  45. void connect(const SocketAddress& address, const Poco::Timespan& timeout);
  46. /// Not supported by this kind of socket.
  47. ///
  48. /// Throws a Poco::InvalidAccessException.
  49. void connectNB(const SocketAddress& address);
  50. /// Not supported by this kind of socket.
  51. ///
  52. /// Throws a Poco::InvalidAccessException.
  53. void bind(const SocketAddress& address, bool reuseAddress = false, bool reusePort = false);
  54. /// Bind a local address to the socket.
  55. ///
  56. /// This is usually only done when establishing a server
  57. /// socket. TCP clients should not bind a socket to a
  58. /// specific address.
  59. ///
  60. /// If reuseAddress is true, sets the SO_REUSEADDR
  61. /// socket option.
  62. void listen(int backlog = 64);
  63. /// Puts the socket into listening state.
  64. ///
  65. /// The socket becomes a passive socket that
  66. /// can accept incoming connection requests.
  67. ///
  68. /// The backlog argument specifies the maximum
  69. /// number of connections that can be queued
  70. /// for this socket.
  71. void close();
  72. /// Close the socket.
  73. int sendBytes(const void* buffer, int length, int flags = 0);
  74. /// Not supported by this kind of socket.
  75. ///
  76. /// Throws a Poco::InvalidAccessException.
  77. int receiveBytes(void* buffer, int length, int flags = 0);
  78. /// Not supported by this kind of socket.
  79. ///
  80. /// Throws a Poco::InvalidAccessException.
  81. int sendTo(const void* buffer, int length, const SocketAddress& address, int flags = 0);
  82. /// Not supported by this kind of socket.
  83. ///
  84. /// Throws a Poco::InvalidAccessException.
  85. int receiveFrom(void* buffer, int length, SocketAddress& address, int flags = 0);
  86. /// Not supported by this kind of socket.
  87. ///
  88. /// Throws a Poco::InvalidAccessException.
  89. void sendUrgent(unsigned char data);
  90. /// Not supported by this kind of socket.
  91. ///
  92. /// Throws a Poco::InvalidAccessException.
  93. bool secure() const;
  94. /// Returns true iff the socket's connection is secure
  95. /// (using SSL or TLS).
  96. Context::Ptr context() const;
  97. /// Returns the SSL context used by this socket.
  98. protected:
  99. ~SecureServerSocketImpl();
  100. /// Destroys the SecureServerSocketImpl.
  101. private:
  102. SecureServerSocketImpl(const SecureServerSocketImpl&);
  103. SecureServerSocketImpl& operator = (const SecureServerSocketImpl&);
  104. private:
  105. SecureSocketImpl _impl;
  106. };
  107. //
  108. // inlines
  109. //
  110. inline Context::Ptr SecureServerSocketImpl::context() const
  111. {
  112. return _impl.context();
  113. }
  114. } } // namespace Poco::Net
  115. #endif // NetSSL_SecureServerSocketImpl_INCLUDED