The C# SqlServer Class

SqlServer publishes a SqlLocalConnection instance for remote SQL clients. It is typically used together with SqlRemoteConnection when an application needs network access to an eXtremeDB database.

For an overview see page SQL Classes

Class Definition

    // ENUM
    public enum SessionState { Wait, Active, Done, Canceled }

    // Nested class OpenParameters
    public class OpenParameters {
        // Configuration Fields
        public SqlLocalConnection conn;
        public int port;
        public int bufsize;
        public int nThreads;
        public int listenQueueSize;
        public bool localDomain;
        public Database.SSLParameters sslParameters;
        public bool authenticationRequired;
        public bool authorizationRequired;
        public int interruptTimeout;
        public String netInterface;
        public int compressionLevel;
        public bool protocolCompatibility;
        public int maxWaitListLength;

        // Constructor
        public OpenParameters(SqlLocalConnection conn, int port);
    }

    // Nested class SessionInfo
    public class SessionInfo {
        public SessionState state;
        public String peerAddr;
        public int peerPort;

        public SessionInfo(SessionState state, String peerAddr, int peerPort);
    }

    // Class SqlServer
    public class SqlServer {
        // Constructors
        public SqlServer(SqlLocalConnection conn, int port, int bufsize);
        public SqlServer(SqlLocalConnection conn, int port);
        public SqlServer(OpenParameters op);

        // Lifecycle Methods
        public void start();
        public void stop();

        // Monitoring Methods
        public SessionInfo[] getSessionsInfo();
    }

Member Descriptions

SessionState enum
Represents the current state of a client session: Wait (idle), Active (processing query), Done (completed), or Canceled (terminated by client).
OpenParameters class
Configuration container for initializing the SQL server with fine-grained control over networking, security, and performance parameters.
OpenParameters.conn
The local SQL connection that the server uses as its database engine. The connection should remain open for the lifetime of the server and is normally dedicated to server-side SQL processing.
OpenParameters.port
TCP port number on which the SQL server will listen for incoming client connections.
OpenParameters.bufsize
Size of the internal I/O buffer in bytes (default: 65536). Affects network throughput and memory usage per connection.
OpenParameters.nThreads
Number of worker threads for handling concurrent client requests (default: 4). Adjust based on CPU cores and expected load.
OpenParameters.listenQueueSize
Maximum length of the pending connection queue (default: 5). Connections exceeding this limit may be rejected under heavy load.
OpenParameters.localDomain
If true, the server uses local-domain transport instead of TCP when this transport is supported by the underlying platform. This is useful for local-only deployments.
OpenParameters.sslParameters
Optional SSL/TLS configuration for encrypting client-server communication. Set to null for unencrypted connections.
OpenParameters.authenticationRequired
If true, clients must provide valid credentials before executing queries. Requires user management setup.
OpenParameters.authorizationRequired
If true, enables authorization checks for authenticated SQL sessions. This setting is typically used together with authenticationRequired.
OpenParameters.interruptTimeout
Timeout in milliseconds for detecting unresponsive client connections (default: 100ms). Helps free resources from stalled sessions.
OpenParameters.netInterface
Optional network interface name or IP address to bind the server to. If null, binds to all available interfaces.
OpenParameters.compressionLevel
Level of network traffic compression (0 = disabled, higher = more compression). Trade-off between CPU usage and bandwidth savings.
OpenParameters.protocolCompatibility
If true, enables protocol compatibility mode for older remote SQL clients.
OpenParameters.maxWaitListLength
Maximum number of requests allowed in the server wait list for a session. A value of 0 keeps the default behavior without an explicit limit.
OpenParameters(SqlLocalConnection, int)
Initializes server configuration with the required local SQL connection and listening port. The remaining fields are initialized to the wrapper defaults, including bufsize=65536, nThreads=4, listenQueueSize=5, localDomain=false, authenticationRequired=false, authorizationRequired=false, interruptTimeout=100, compressionLevel=0, protocolCompatibility=false, and maxWaitListLength=0.
SessionInfo class
Represents runtime information about a client session known to the SQL server.
SessionInfo.state
Current processing state of the session (see SessionState enum).
SessionInfo.peerAddr
IP address or hostname of the connected client.
SessionInfo.peerPort
Source port number used by the client for this connection.
SessionInfo(SessionState, String, int)
Constructs a session info object. Typically instantiated internally by the server wrapper.
SqlServer(SqlLocalConnection, int, int)
Creates a SQL server over an existing SqlLocalConnection, listening on the specified port and using the specified buffer size. The supplied local connection should stay connected until the server is stopped.
SqlServer(SqlLocalConnection, int)
Convenience constructor: creates a server with default buffer size (65536 bytes).
SqlServer(OpenParameters)
Creates a server using full configuration via OpenParameters. Use this constructor when SSL, authentication, protocol compatibility, binding options, or other server settings need to be customized.
start()
Starts the SQL server so that remote SQL clients can connect using the configured transport, security, and buffering parameters. Request processing is handled by the server worker threads.
stop()
Gracefully shuts down the SQL server: stops accepting new connections, terminates server-side activity, and releases server resources. Call this method before disconnecting the underlying SqlLocalConnection.
getSessionsInfo()
Returns an array of SessionInfo objects describing the client sessions currently known to the server. This method can be used for runtime monitoring and diagnostics.
Thread Safety
The SqlServer instance is thread-safe for concurrent client access. However, the underlying SqlLocalConnection must remain dedicated to the server and not be used directly by application threads.
Resource Management
Always call stop() before disposing the associated database connection to ensure clean shutdown and prevent resource leaks.