Home | C-Bits Package Documentation | Project Page |
#include <SSLServerSocket.h>
Inheritance diagram for cbits::SSLServerSocket:
Public Methods | |
SSLServerSocket (const int port, const int qdepth=20, SSLContext *const ctxt=0) throw ( SocketException ) | |
Construct an SSL-enabled server socket. More... | |
virtual SSLSocket * | accept (const long int msec=0) throw ( SocketException ) |
Accept the next SSL connection on this server socket. More... | |
void | close () |
Close the server socket. More... | |
socket_t | getHandle () const |
Access the BSD socket descriptor. More... | |
const bool | isError () const |
Determine if the server socket is an error condition. More... | |
const std::string & | getError () const |
Get human readable description of the last error, if any. More... | |
const int | getSockOpt (const int level, const int op_name, char *result, int *result_len) const |
Set a socket option on the server socket. More... | |
std::ostream * | getLogger () const |
Access this ServerSocket's debug logging stream. More... | |
std::ostream * | getLocalLogger () const |
Access this ServerSocket's individual logging stream, set via cbits::ServerSocket::setLocalLogger, if any. More... | |
void | setLocalLogger (std::ostream *os) const |
Set the instance debug logging stream for this ServerSocket. More... | |
void | closeLocalLogger () const |
Close this ServerSocket's individually set debug log stream, set via cbits::ServerSocket::setLocalLogger, if any. More... | |
Static Public Methods | |
void | setGlobalContext (SSLContext *g_ctxt) throw ( SSLContextException ) |
Set a SSL context to be used by ALL new SSLServerSocket instances. More... | |
std::ostream * | getGlobalLogger () |
Access the global debug logging stream for all ServerSocket instances that don't have an individual logging streams. More... | |
void | setGlobalLogger (std::ostream *os) |
Set a global debug logging stream to be used by all ServerSocket instances. More... | |
void | closeGlobalLogger () |
Close the globally set debug log stream, set via cbits::ServerSocket::setGlobalLogger, if any. More... | |
Protected Methods | |
virtual const socket_t | accept_h (const long int msec=0) throw ( SocketException ) |
Low level method to accept the next client network connection. More... | |
Socket * | get_tcp_socket () const |
Get a reference to the cbits::Socket instance used by this ServerSocket to bind to the server port. More... | |
Protected Attributes | |
bool | _error |
errno value of the last error that occurred. More... | |
std::string | _errstr |
A human readable description of _error, if any. More... | |
std::ostream * | _llogr |
Debug logging sream for this instance, if set. More... | |
Static Protected Attributes | |
std::ostream * | _glogr = 0 |
Global, default logging stream for all cbits::ServerSocket instances, if set. More... | |
Private Attributes | |
BIO * | _bio |
OpenSSL BIO object wrapping the low-level BSD socket. More... | |
SSLContext * | _ctxt |
The SSL context for this SSLServerSocket. More... | |
CriticalSection | _csect |
Critical section to prevent multiple threads from invoking cbits::SSLServerSocket::accept simultaneously. More... | |
Static Private Attributes | |
SSLContext * | _global_ctxt |
The global, default SSL security context, if set. More... |
The OpenSSL library (http://www.openssl.org) is used to provide SSL-related functionality and X.509 certificate handling.
From the user's perspective, a cbits::SSLServerSocket is (in principle) identical to a cbits::ServerSocket in terms of functionality after the network connection has been established and the SSL handshake has succeeded.
However, all SSL sockets have to be created within a particular SSL context that defines parameters and data used during the SSL handshake, such as what ciphers are allowed (or not) and the location of relevant X.509 certificates.
The cbits::SSLContext class is used to represent an SSL security context for establishing SSL network connections. An instance of cbits::SSLContext should be provided to the cbits::SSLServerSocket constructor or set globally, in advance, for all (future) SSLServerSocket instances via the cbits::SSLServerSocket::setGlobalContext method.
Further, all cbits::SSLSocket connections produced from a cbits::SSLServerSocket, as a result of the SSL-enabled server accepting SSL connections from remote clients, inherit the cbits::SSLContect of the cbits::SSLServerSocket that produced them.
|
Construct an SSL-enabled server socket. port - the port to accept client connections on. Returns: ------------ n/a Exceptions: ----------- SocketException - if the socket can not be created.
|
|
Accept the next SSL connection on this server socket.
Reimplemented from cbits::ServerSocket. |
|
Low level method to accept the next client network connection. This method could be reimplemented in a derived class that does this differently (on a different platform, say).
|
|
Close the server socket.
|
|
Close the globally set debug log stream, set via cbits::ServerSocket::setGlobalLogger, if any. Since the output stream supplied to cbits::ServerSocket::setGlobalLogger is externally created, the output stream itself is not closed by this action. This action does not affect any cbits::Socket instances created by this ServerSocket. |
|
Close this ServerSocket's individually set debug log stream, set via cbits::ServerSocket::setLocalLogger, if any. Since the output stream supplied to cbits::ServerSocket::setLocalLogger is externally created, the output stream itself is not closed by this action. This action does not affect any cbits::Socket instances created by this ServerSocket. |
|
Get a reference to the cbits::Socket instance used by this ServerSocket to bind to the server port.
|
|
Get human readable description of the last error, if any.
|
|
Access the global debug logging stream for all ServerSocket instances that don't have an individual logging streams. This only accesses the logging stream that is used by ServerSocket instances that haven't been individually configured with their own logging stream via cbits::ServerSocket::setLocalLogger.
|
|
Access the BSD socket descriptor.
|
|
Access this ServerSocket's individual logging stream, set via cbits::ServerSocket::setLocalLogger, if any.
|
|
Access this ServerSocket's debug logging stream. A pointer to a stream is always returned. Logging statements that use this method should perform runtime checks to determine if application debug logging is enabled.
|
|
Set a socket option on the server socket.
|
|
Determine if the server socket is an error condition.
|
|
Set a SSL context to be used by ALL new SSLServerSocket instances. This may be overridden for individual SSLServerSocket instances by supplying a different context to the SSLServerSocket constructor when the SSLServerSocket is created.
|
|
Set a global debug logging stream to be used by all ServerSocket instances. This does not override a ServerSocket instance's individual logging stream, if any, set via cbits::ServerSocket::setLocalLogger. This method is a useful way to provide a default logging stream to all ServerSocket instances, without having to configure each instance separately, but still be able to set the logging stream for specific ServerSocket instances. If this ServerSocket doesn't have an individual logging stream configured, the global logging stream (if set) is used to configure the logging stream for all cbits::Socket instances created by this ServerSocket.
|
|
Set the instance debug logging stream for this ServerSocket. This logger is also configured for all cbits::Socket instances that are created by this ServerSocket. |
|
OpenSSL BIO object wrapping the low-level BSD socket.
|
|
Critical section to prevent multiple threads from invoking cbits::SSLServerSocket::accept simultaneously.
Reimplemented from cbits::ServerSocket. |
|
The SSL context for this SSLServerSocket.
|
|
errno value of the last error that occurred.
|
|
A human readable description of _error, if any.
|
|
The global, default SSL security context, if set.
|
|
Global, default logging stream for all cbits::ServerSocket instances, if set.
|
|
Debug logging sream for this instance, if set.
|
|
|