# The C++ SqlServer Class

> The SqlServer class executes client SQL requests.

> ### For an overview see page C++ Classes

> The SqlServer methods are described in the table below.

> SqlServer(McoSqlEngine* engine, int port, size_t bufferSize = 64 * 1024, size_t nThreads = 8, int listenQueueSize = 5, error_handler_t handler = NULL, bool localDomain = false, void* sslParameters = NULL, bool authenticationRequired = false, int interruptTimeout = 100, int compressionLevel = 0); | Constructor of the SQL server; the arguments are defined as follows
> engine | The local McoSqlEngine instance
> port | The server port
> bufferSize | The size of the transfer buffer. Results of client query execution will be placed in this buffer. If the result data source can not fit into the buffer then the query result will be delivered to the client in parts. In this case a transaction lock is kept until all the results are sent to the client.
> nThreads | The optimal number of threads spawned by server. The server will spawn as many threads as client requests arrives. Each thread processes requests from the client until the client closes the connection. After this the thread is returned to the pool of idle threads or is terminated if the number of threads exceeds the optimal number specified.
> listenQueueSize | The paremeter of the socket listen function; means the maximal number of connections that can be concurrently accepted by the server
> handler | An optional error handler
> localDomain | Indicates that Unix Domain Socket instead of networked TCP socket is used for RSQL communication which is possible only when server and client are on the same host
> sslParameters | A pointer to a `mco_ssl_params_t` structure containing SSL connection settings
> authenticationRequired | Indicates whether authentication is required for clients
> interruptTimeout | The period in milliseconds to poll the interrupts from the client(s). If 0, disable interruption
> compressionLevel | Compression level: 0 = no compression, 1 = best speed, 9 - best compression. Default value is 0
> SqlServer(const OpenParameters &params); | This constructor instantiates the server with the arguments specified in the OpenParameters structure defined as follows (the meanings of these arguments are defined in the constructor above):
>       struct OpenParameters {
>         McoSqlEngine   *engine;
>         int             port;
>         size_t          bufferSize;
>         size_t          nThreads;
>         int             listenQueueSize;
>         error_handler_t handler;
>         bool            localDomain;
>         void          * sslParameters;
>         bool            authenticationRequired;
>         int             interruptTimeout;
>         const char     *netInterface;
>         int             nGcThreads;
>         int             gcPeriod;
>         OpenParameters(McoSqlEngine *eng, int p) :
>           engine(eng), port(p),
>           bufferSize(64 * 1024),
>            nThreads(8),
>           listenQueueSize(5),
>           handler(0),
>            localDomain(false),
>           sslParameters(0),
>           authenticationRequired(false),
>           interruptTimeout(100),
>           netInterface(0),
>           nGcThreads(0),
>           gcPeriod(100) {}
>       };
> void start(); | Starts the server; opens a socket at the specified port and accepts client connection requests
> void stop(); | Stops the server; stops accepting connection requests and closes the server socket
> void getSessionsInfo(session_info_handler_t handler, void* context = NULL); | Enumerates sessions in a wait state followed by active sessions
> void regSessionEvent(session_info_handler_t handler, void* context = NULL); | Registers a callback to receive new session start \ stop events
> void regQueryInfoEvent(query_info_handler_t handler, void* context = NULL); | Registers a callback to receive query statistic events
> ~SqlServer(); | Destructor