SecureServerSocket.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // SecureServerSocket.h
  3. //
  4. // $Id: //poco/Main/NetSSL_OpenSSL/include/Poco/Net/SecureServerSocket.h#7 $
  5. //
  6. // Library: NetSSL_OpenSSL
  7. // Package: SSLSockets
  8. // Module: SecureServerSocket
  9. //
  10. // Definition of the SecureServerSocket class.
  11. //
  12. // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH.
  13. // and Contributors.
  14. //
  15. // Permission is hereby granted, free of charge, to any person or organization
  16. // obtaining a copy of the software and accompanying documentation covered by
  17. // this license (the "Software") to use, reproduce, display, distribute,
  18. // execute, and transmit the Software, and to prepare derivative works of the
  19. // Software, and to permit third-parties to whom the Software is furnished to
  20. // do so, all subject to the following:
  21. //
  22. // The copyright notices in the Software and this entire statement, including
  23. // the above license grant, this restriction and the following disclaimer,
  24. // must be included in all copies of the Software, in whole or in part, and
  25. // all derivative works of the Software, unless such copies or derivative
  26. // works are solely in the form of machine-executable object code generated by
  27. // a source language processor.
  28. //
  29. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  30. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  31. // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  32. // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  33. // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  34. // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  35. // DEALINGS IN THE SOFTWARE.
  36. //
  37. #ifndef NetSSL_SecureServerSocket_INCLUDED
  38. #define NetSSL_SecureServerSocket_INCLUDED
  39. #include "Poco/Net/NetSSL.h"
  40. #include "Poco/Net/ServerSocket.h"
  41. #include "Poco/Net/Context.h"
  42. namespace Poco {
  43. namespace Net {
  44. class NetSSL_API SecureServerSocket: public ServerSocket
  45. /// A server socket for secure SSL connections.
  46. {
  47. public:
  48. SecureServerSocket();
  49. /// Creates a SSL server socket using the
  50. /// default SSL server context.
  51. ///
  52. /// The server socket must be bound to
  53. /// an address and put into listening state.
  54. explicit SecureServerSocket(Context::Ptr pContext);
  55. /// Creates a SSL server socket, using the
  56. /// given SSL context object.
  57. ///
  58. /// The server socket must be bound to
  59. /// an address and put into listening state.
  60. SecureServerSocket(const Socket& socket);
  61. /// Creates the SecureServerSocket with the SocketImpl
  62. /// from another socket. The SocketImpl must be
  63. /// a SecureServerSocketImpl, otherwise an InvalidArgumentException
  64. /// will be thrown.
  65. SecureServerSocket(const SocketAddress& address, int backlog = 64);
  66. /// Creates a server socket using the default server SSL context,
  67. /// binds it to the given address and puts it in listening
  68. /// state.
  69. ///
  70. /// After successful construction, the server socket
  71. /// is ready to accept connections.
  72. SecureServerSocket(const SocketAddress& address, int backlog, Context::Ptr pContext);
  73. /// Creates a server socket using the given SSL context, binds it
  74. /// to the given address and puts it in listening
  75. /// state.
  76. ///
  77. /// After successful construction, the server socket
  78. /// is ready to accept connections.
  79. SecureServerSocket(Poco::UInt16 port, int backlog = 64);
  80. /// Creates a server socket using the default server SSL context,
  81. /// binds it to the given port and puts it in listening
  82. /// state.
  83. ///
  84. /// After successful construction, the server socket
  85. /// is ready to accept connections.
  86. SecureServerSocket(Poco::UInt16 port, int backlog, Context::Ptr pContext);
  87. /// Creates a server socket using the given SSL context, binds it
  88. /// to the given port and puts it in listening
  89. /// state.
  90. ///
  91. /// After successful construction, the server socket
  92. /// is ready to accept connections.
  93. virtual ~SecureServerSocket();
  94. /// Destroys the StreamSocket.
  95. SecureServerSocket& operator = (const Socket& socket);
  96. /// Assignment operator.
  97. ///
  98. /// Releases the socket's SocketImpl and
  99. /// attaches the SocketImpl from the other socket and
  100. /// increments the reference count of the SocketImpl.
  101. StreamSocket acceptConnection(SocketAddress& clientAddr);
  102. /// Get the next completed connection from the
  103. /// socket's completed connection queue.
  104. ///
  105. /// If the queue is empty, waits until a connection
  106. /// request completes.
  107. ///
  108. /// Returns a new SSL socket for the connection
  109. /// with the client.
  110. ///
  111. /// The client socket's address is returned in clientAddr.
  112. StreamSocket acceptConnection();
  113. /// Get the next completed connection from the
  114. /// socket's completed connection queue.
  115. ///
  116. /// If the queue is empty, waits until a connection
  117. /// request completes.
  118. ///
  119. /// Returns a new SSL socket for the connection
  120. /// with the client.
  121. Context::Ptr context() const;
  122. /// Returns the SSL context used by this socket.
  123. };
  124. } } // namespace Poco::Net
  125. #endif // NetSSL_SecureServerSocket_INCLUDED