TCP Server
Overview
The TCP Server is one of the three real-time communication servers provided by Diarkis, allowing the implementation of custom commands for applications.
A command is a formatted packet sent from the client and processed by the server. This is how Diarkis server clusters interact with clients.
Setting Up the TCP Server
To expose built-in commands to clients, you can set it up using the diarkisexec
package.
You can expose built-in commands by specifying the module with
diarkisexec.SetupDiarkis()
. You can customize the settings by specifying theConfigPath
for each module.You can expose custom commands with
diarkisexec.SetServerCommandHandler()
.You can set up a UDP server with
diarkisexec.SetupDiarkisUDPServer()
. The server settings can be customized with a JSON file as an argument.
⚠️ Note that the above functions must be executed before calling
diarkisexec.StartDiarkis()
.
For more details, refer to the diarkisexec API Reference.
Mesh Configuration
Specify the path to the JSON file with meshConfigPath
. For details, refer to the Mesh Configuration.
TCP Server Configuration
The configuration is described in JSON.
Key | Default | |
---|---|---|
connectionTTL | 10 | TTL for the connection. If this time is exceeded, the client will be disconnected from the server. |
address | "127.0.0.1" | Address to bind the UDP server |
nic | "eth0" | Interface name to obtain the address. Used if the address is not specified. |
port | "7100" | Port for the UDP server to bind. The UDP server automatically searches for available ports starting from the specified port. |
maxRcvSize | 8000 | Maximum TCP packet size (in bytes) for each request packet |
noDelay | false | If set to true, the Nagle algorithm is disabled (no buffering before writing) |
enableEncryption | true | If set to false, packet encryption and decryption are disabled. The HTTP server must also be configured similarly. |
⚠️ In a cloud environment, set the address to a private IP address and use the environment variable
DIARKIS_CLOUD_ENV
.
For more details, refer to the server API Reference.
最終更新