Threaded TCP Server.  
 More...
#include <ktthserv.h>
List of all members.
| 
Classes | 
| class | Logger | 
|  | Interface to log internal information and errors.  More... 
 | 
| class | Session | 
|  | Interface to access each session data.  More... 
 | 
| class | SessionTask | 
|  | Task with a session. 
 | 
| class | TaskQueueImpl | 
|  | Task queue implementation. 
 | 
| class | Worker | 
|  | Interface to process each request.  More... 
 | 
| 
Public Member Functions | 
|  | ThreadedServer () | 
|  | Default constructor. 
 | 
|  | ~ThreadedServer () | 
|  | Destructor. 
 | 
| void | set_network (const std::string &expr, double timeout=-1) | 
|  | Set the network configurations. 
 | 
| void | set_logger (Logger *logger, uint32_t kinds=Logger::SYSTEM|Logger::ERROR) | 
|  | Set the logger to process each log message. 
 | 
| void | set_worker (Worker *worker, size_t thnum=1) | 
|  | Set the worker to process each request. 
 | 
| bool | start () | 
|  | Start the service. 
 | 
| bool | stop () | 
|  | Stop the service. 
 | 
| bool | finish () | 
|  | Finish the service. 
 | 
| void | log (Logger::Kind kind, const char *format,...) | 
|  | Log a message. 
 | 
| void | log_v (Logger::Kind kind, const char *format, va_list ap) | 
|  | Log a message. 
 | 
| int64_t | connection_count () | 
|  | Get the number of connections. 
 | 
| int64_t | task_count () | 
|  | Get the number of tasks in the queue. 
 | 
| bool | aborted () | 
|  | Check whether the thread is to be aborted. 
 | 
Detailed Description
Constructor & Destructor Documentation
Member Function Documentation
Set the network configurations. 
- Parameters:
- 
  
    | expr | an expression of the address and the port of the server. |  | timeout | the timeout of each network operation in seconds. If it is not more than 0, no timeout is specified. |  
 
 
 
Set the logger to process each log message. 
- Parameters:
- 
  
  
 
 
Set the worker to process each request. 
- Parameters:
- 
  
    | worker | the worker object. |  | thnum | the number of worker threads. |  
 
 
 
Start the service. 
- Returns:
- true on success, or false on failure. 
- Note:
- This function blocks until the server stops by the ThreadedServer::stop method. 
 
 
Stop the service. 
- Returns:
- true on success, or false on failure. 
 
 
Finish the service. 
- Returns:
- true on success, or false on failure. 
 
 
Log a message. 
- Parameters:
- 
  
    | kind | the kind of the event. Logger::DEBUG for debugging, Logger::INFO for normal information, Logger::SYSTEM for system information, and Logger::ERROR for fatal error. |  | format | the printf-like format string. The conversion character `' can be used with such flag characters as `s', `d', `o', `u', `x', `X', `c', `e', `E', `f', `g', `G', and `'. |  | ... | used according to the format string. |  
 
 
 
Log a message. 
- Note:
- Equal to the original Cursor::set_value method except that the last parameters is va_list. 
 
 
Get the number of connections. 
- Returns:
- the number of connections. 
 
 
Get the number of tasks in the queue. 
- Returns:
- the number of tasks in the queue. 
 
 
Check whether the thread is to be aborted. 
- Returns:
- true if the thread is to be aborted, or false if not.