Home | C-Bits Package Documentation | Project Page |
#include <ServerSocket.h>
Inheritance diagram for cbits::ServerSocket:
Public Methods | |
ServerSocket (const int port, const int qdepth=15) throw ( SocketException ) | |
Construct a cbits::ServerSocket instance that can accept client network connections on a specified local port. More... | |
virtual | ~ServerSocket () |
Destructor. More... | |
virtual Socket * | accept (const long int msec=0) throw ( SocketException ) |
Accept the next 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 | |
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 | |
Socket * | _ssock |
The cbits::Socket instance used to bind to the local server port. More... | |
CriticalSection | _read_csect |
Critical section object used to synchronize access to the error status of this ServerSocket. More... | |
CriticalSection | _csect |
Critical section object used to prevent multiple threads from simultaneously calling cbits::ServerSocket::accept. More... |
In practice, cbits::ServerSocket acts like a cbits::Socket factory, generating a separate instance of cbits::Socket (via cbits::ServerSocket::accept) for each client network connection it accepts.
|
Construct a cbits::ServerSocket instance that can accept client network connections on a specified local port.
|
|
Destructor. Releases the server port and destroys this cbits::ServerSocket instance. |
|
Accept the next connection on this server socket.
Reimplemented in cbits::SSLServerSocket. |
|
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 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. |
|
Critical section object used to prevent multiple threads from simultaneously calling cbits::ServerSocket::accept.
Reimplemented in cbits::SSLServerSocket. |
|
errno value of the last error that occurred.
|
|
A human readable description of _error, if any.
|
|
Global, default logging stream for all cbits::ServerSocket instances, if set.
|
|
Debug logging sream for this instance, if set.
|
|
Critical section object used to synchronize access to the error status of this ServerSocket.
|
|
The cbits::Socket instance used to bind to the local server port.
|
|
|