Keywords: Basic Configuration, Configuration Documentation
<?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>
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:
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:
certificate: it is a configuration element for X509Certificate which will be used in this server instance
there are two usage:
one is load certificate from cert file
<certificate filePath="localhost.pfx" password="supersocket" />
another one is load certificate from local certificate storage
<certificate storeName="My" storeLocation="LocalMachine" thumbprint="f42585bceed2cb049ef4a3c6d0ad572a6699f6f3"/>
connectionFilter: the name of the connection filter you want to use for this server instance, multiple filters should be delimited by ',' or ';'. Connection filters should be defined in a child nodes of root node which will be introduced in the following documentation;
commandLoader: the name of the command loader you want to use for this server instance, multiple loaders should be delimited by ',' or ';'. Command loaders should be defined in a child nodes of root node which will be introduced in the following documentation;
logFactory: the log factory you want to use for this server instance. If you don't set it, the log factory defined in root configuration will be used;
listeners: it is an configuration element which is designed for supporting multiple listening ip/port pair in one server instance. The listeners node should contains one or more child nodes of listener whose attributes defined like below:
ip: the listening ip;
port: the listening port;
backlog: the listening back log size;
security: the security mode (None/Default/Tls/Ssl/...);
for examples:
<server name="EchoServer" serverTypeName="EchoService">
<listeners>
<add ip="Any" port="2012" />
<add ip="IPv6Any" port="2012" />
</listeners>
</server>
receiveFilterFactory: the name of the receive filter factory you want to use it for this server instance;
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>
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>
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:
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 ';'