-
Notifications
You must be signed in to change notification settings - Fork 6
Scripted tcp server
Ushakov Michael (Ушаков Михаил) edited this page Jun 20, 2018
·
2 revisions
For using scripted tcp server we have to use FlexibleTcpServer (implementation on ITcpServer in MossbauerLab.TinyTcpServer.Core). Script can implement ANY functionality (i.e. SMTP, FTP or even HTTP server) For working with script we MUST have entry method in class ServerScript:
public void Init(ref ITcpServer server)
Full script example is here (echo server):
For using FlexibleTcpServer me must pass 1 obligatory parameter - Server script file and 3 optional (ipaddress, port and server setting). If optional parameter were not passed it uses default values:
- ip address - 127.0.0.1
- tcp port - 16000
- server settings with default values (see code)
Example of how to use FlexibleTcpServer is very simple: `
private const String LocalIpAddress = "127.0.0.1";
private const UInt16 ServerPort = 8044;
private const String Script = @"..\..\TestScripts\SimpleScript.cs";
private ITcpServer _server;
public void Init()
{
CompilerOptions options = new CompilerOptions();
// assign options properties (see Console project 4 examples
_server = new FlexibleTcpServer(Script, LocalIpAddress, ServerPort, options);
}
`