SuperSocket Basic Configuration

Keywords: Basic Configuration, Configuration Documentation

A Sample Configuration

<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="superSocket"
                 type="SuperSocket.SocketEngine.Configuration.SocketServiceConfig, SuperSocket.SocketEngine" />
    </configSections>
    <appSettings>
        <add key="ServiceName" value="SupperSocketService" />
    </appSettings>
    <superSocket>
        <servers>
            <server name="TelnetServerA"
                    serverTypeName="TelnetServer"
                    ip="Any"
                    port="2020">
            </server>
            <server name="TelnetServerB"
                    serverTypeName="TelnetServer"
                    ip="Any"
                    port="2021">
            </server>
        </servers>
        <serverTypes>
            <add name="TelnetServer"
                 type="SuperSocket.QuickStart.TelnetServer_StartByConfig.TelnetServer, SuperSocket.QuickStart.TelnetServer_StartByConfig"/>
        </serverTypes>
    </superSocket>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
    </startup>
</configuration>

Root Configuration

The configuration node "superSocket" is the root of the SuperSocket configuration, it defines the global parameters of SuperSocket requires. Let me explain all the attributes of the root node:

Servers Configuration

In the root configuration node, there is child node named "servers", you can define one or many server configuration nodes in it which represent app server instances. The server instances can be same AppServer type, also can be different AppServer types. All server node's attributes:

Server Types Configuration

Server types node is a collection configuration node under the root. You are able to add one/more elements with element name "add" and attributes "name" and "type":

    <serverTypes>
        <add name="TelnetServerType"
             type="SuperSocket.QuickStart.TelnetServer_StartByConfig.TelnetServer, SuperSocket.QuickStart.TelnetServer_StartByConfig"/>
    </serverTypes>

Because of the defined server type's name is "TelnetServerType", you can set the config attribute "serverTypeName" of the server instances you want to run as this type to be "TelnetServerType":

    <server name="TelnetServerA"
            serverTypeName="TelnetServerType"
            ip="Any"
            port="2020">
    </server>

Log Factories Configuration

Same as server type configuration, you also can define one or more log factories and use it in server, the only one difference is the log factory also can be set in root configuration:

<logFactories>
  <add name="ConsoleLogFactory"
       type="SuperSocket.SocketBase.Logging.ConsoleLogFactory, SuperSocket.SocketBase" />
</logFactories>

Use it in root configuration:

<superSocket logFactory="ConsoleLogFactory">
    ...
    ...
</superSocket>

Use it in server node:

<server name="TelnetServerA"
       logFactory="ConsoleLogFactory"
       ip="Any"
       port="2020">
</server>

Configuration Intellisense

SuperSocket provides online XSD (XML Schema Document) file to help your configuration. You just need to add 3 extra lines in your SuperSocket configuration section:

  <superSocket xmlns="http://schema.supersocket.net/supersocket"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://schema.supersocket.net/supersocket http://schema.supersocket.net/v1-6/supersocket.xsd">
    <!---->
  </superSocket>

Then you will get the intelligent auto completion function when you update the configuration:

SuperSocket Configuration Intellisense

SuperSocket Windows Service Configuration

As you know, SuperSocket provides a running container "SuperSocket.SocketService.exe" which can run as a windows service.

You can define the windows service's name by configuring:

<appSettings>
    <add key="ServiceName" value="SuperSocketService" />
</appSettings>

There are some other configuration attributes for the windows service:

ServiceDescription: the description of this windows service
ServicesDependedOn: the other windows service which this service depends on; this windows service will start after the depended windows service; multiple depended service should be separated by character ',' or ';'