You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ushakov Michael (Ушаков Михаил) edited this page Nov 4, 2017
·
2 revisions
It usage is quite simple, full code your could see in unit tests project in solution, but shortly it is written below:
`
// somewhere server declared and logger too
private ITcpServer _server;
private readonly ILog _logger;
// Configure logger i.e. in constructor of class uses TinyTcpServer (TestTcpServer)
XmlConfigurator.Configure();
_logger = LogManager.GetLogger(typeof(TestTcpServer));
// instantiation server and passing to it Echo client handler
_server = new TcpServer("127.0.0.1", 6666, _logger, true);
_server.AddHandler(_clientHandlerInfo, EchoTcpClientHandler.Handle);
// starting server
_server.Start();
// from this moment it works in own thread and calling EchoTcpClientHandler.Handle of type Func<Byte[], TcpClientHandlerInfo, Byte[]> to proccess received data
// when we don't need server anymore we should stop it
_server.Stop(true); // parameters responsible for handlers removinf i.e. for replacing Echo Handler with another type of handler.
// and dispose when server won't be started again
_server.Dispose();