SecureServerSocketImpl.h 3.8 KB

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