All Projects → MossbauerLab → Tinytcpserver

MossbauerLab / Tinytcpserver

Licence: gpl-3.0
A small tcp server working under Mono or .NET (4.0) and provides hooks for handling data exchange with clients (works under mono and .net). Behaviour/protocol/reaction could be specified via custom C# script.

Projects that are alternatives of or similar to Tinytcpserver

Oksocket
An blocking socket client for Android applications.
Stars: ✭ 2,359 (+16750%)
Mutual labels:  server, tcp, socket, tcp-server, tcp-client
Deta cache
缓存cache服务器
Stars: ✭ 106 (+657.14%)
Mutual labels:  server, network, tcp, socket, tcp-server
Simplenet
An easy-to-use, event-driven, asynchronous network application framework compiled with Java 11.
Stars: ✭ 164 (+1071.43%)
Mutual labels:  server, network, tcp, tcp-server, tcp-client
Socketify
Raw TCP and UDP Sockets API on Desktop Browsers
Stars: ✭ 67 (+378.57%)
Mutual labels:  socket, tcp, tcp-server, tcp-client
tcp-net
Build tcp applications in a stable and elegant way
Stars: ✭ 42 (+200%)
Mutual labels:  socket, tcp, tcp-server, tcp-client
EasyFileTransfer
An easy way to transfer file with any size on network with tcp protocol.
Stars: ✭ 30 (+114.29%)
Mutual labels:  socket, tcp, tcp-server, tcp-client
Simpletcp
Simple wrapper for TCP client and server in C# with SSL support
Stars: ✭ 99 (+607.14%)
Mutual labels:  server, tcp, tcp-server, tcp-client
React Native Tcp Socket
React Native TCP socket API for Android, iOS & macOS with client SSL/TLS support
Stars: ✭ 112 (+700%)
Mutual labels:  network, tcp, tcp-server, tcp-client
Zserver4d
ZServer4D 是一套从商业项目剥离而出的云服务器中间件,可以承载百万级的分布式负载服务,并且支持IoT及内网穿透
Stars: ✭ 199 (+1321.43%)
Mutual labels:  server, network, tcp, socket
Pesocket
A C# Network Library.
Stars: ✭ 134 (+857.14%)
Mutual labels:  server, network, socket, tcp-ip
Bizsocket
异步socket,对一些业务场景做了支持
Stars: ✭ 469 (+3250%)
Mutual labels:  tcp, socket, tcp-server, tcp-client
tcp server client
A thin and simple C++ TCP client server
Stars: ✭ 124 (+785.71%)
Mutual labels:  tcp, tcp-server, tcp-client, tcp-ip
cAndroid
cAndroid is tool for control your PC by Android phone
Stars: ✭ 23 (+64.29%)
Mutual labels:  socket, tcp-server, tcp-client
network
exomia/network is a wrapper library around System.Socket for easy and fast TCP/UDP client & server communication.
Stars: ✭ 18 (+28.57%)
Mutual labels:  tcp, tcp-server, tcp-client
SuperSimpleTcp
Simple wrapper for TCP client and server in C# with SSL support
Stars: ✭ 263 (+1778.57%)
Mutual labels:  tcp, tcp-server, tcp-client
ctsTraffic
ctsTraffic is a highly scalable client/server networking tool giving detailed performance and reliability analytics
Stars: ✭ 125 (+792.86%)
Mutual labels:  tcp, tcp-server, tcp-client
Hprose Nodejs
Hprose is a cross-language RPC. This project is Hprose 2.0 for Node.js
Stars: ✭ 297 (+2021.43%)
Mutual labels:  tcp, tcp-server, tcp-client
Message Io
Event-driven message library for building network applications easy and fast.
Stars: ✭ 321 (+2192.86%)
Mutual labels:  network, tcp, tcp-server
AsyncTcpClient
An asynchronous variant of TcpClient and TcpListener for .NET Standard.
Stars: ✭ 125 (+792.86%)
Mutual labels:  tcp, tcp-server, tcp-client
Hisocket
It is a lightweight client socket solution, you can used it in C# project or Unity3d
Stars: ✭ 275 (+1864.29%)
Mutual labels:  network, tcp, socket

TinyTcpServer

1. OVERVIEW

A small tcp server working under Mono or .NET (4.0) and provides hooks for handling data exchange with MULTIPLE clients (works under mono and .net) and BEHAVIOUR CUSTOMIZATION via C# SCRIPT. It was fully tested with NUnit Tests on single and multi client (parallel) exchange.

Also we written 2 simple implementations (protocols) over ITcpServer in separate project: Echo server (RFC 862) Time server (RFC 868)

2. SOLUTION STRUCTURE

/   
   ----/Console
   ----/GUI
   ----TinyTcpServer/

              ----MossbauerLab.TinyTcpServer.Core
              ----MossbauerLab.TinyTcpServer.Core.FunctionalTests
              ----MossbauerLab.SimpleExtensions
              ----MossbauerLab.SimpleExtensions.Tests

/Console is a console project with management console (build for FlexibleTcpServer working with scripts) /GUI is a Windows Forms Tool for management server (build for FlexibleTcpServer working with scripts) /TinyTcpServer is a solution with server interface and it extensions (differnt implementation) including FlexibleTcpServer

3. NUGET PACKAGE

https://www.nuget.org/packages/MossbauerLab.TinyTcpServer.Core/

4. FULL EXAMPLE OF HOW TO USE

`

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();
    CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary<String, String>()
    {
        {"CompilerVersion", "v4.0"}
    });
    options.Parameters = new CompilerParameters(new string[] {"System.Web"});
    options.Parameters.GenerateExecutable = false;
    options.Parameters.GenerateInMemory = true;
    options.ScriptEntryType = "TestEchoScript.EchoScript";
    
    _server = new FlexibleTcpServer(Script, LocalIpAddress, ServerPort);    
}

`

/*That is all ! all logics is inside you script There are requirement to presence of initial class and entry method. Full examples could be found in

  • MossbauerLab.TinyTcpServer.Core.FunctionalTests/Server/TestFlexibleTcpServer.cs
  • In Console and GUI projects with Utils class for getting CompilerOptions and TcpServerConfig from very simple files (Key=Value) */

`

 public class ServerScript
 {
     public void Init(ref ITcpServer server)
     {
         if(server == null)
             throw new NullReferenceException("server");
         _server = server;
         _connectHandlerId = Guid.NewGuid();
         _dataHandlerId = Guid.NewGuid();
         //Console.WriteLine("Init....");
         _server.AddConnectionHandler(_connectHandlerId, OnClientConnection);
         _server.AddHandler(new TcpClientHandlerInfo(_dataHandlerId), OnClientExchange);
     }
     // ...
 }

 // in this method we set up handlers
 // Handlers on Connect and Exchange looks like:
 public Byte[] OnClientExchange(Byte[] receivedData, TcpClientHandlerInfo info)
 {
     lock (receivedData)
     {
         Byte[] outputData = new Byte[receivedData.Length];
         Array.Copy(receivedData, outputData, receivedData.Length);
         return outputData;
     }
 }
 
 // connect true if client connected and false if disconnected 
 public void OnClientConnection(TcpClientContext context, Boolean connect)  
 
 {
        
 }

`

Full example present (in file SimpleScript inside MossbauerLab.TinyTcpServer.FunctionalTests

5 Expanded setting

There are additional settings for TcpServer -> see class TcpServerSettings.cs (MossbauerLab.TinyTcpServer.Core) In Console project there is a class that could parse config ftle (key=value) with that settings class is TcpServerConfigBuilder

it handles file, examples of settings: `

 # number of clients processing the 'same time'
 ParallelTask = 256
 # buffer on receive for every client (in bytes)
 ClientBufferSize = 65535
 # chunk is a auant of size for read and write operations
 ChunkSize = 4096
 # number of times in a row that calls BeginAccept (in a sepatarate from IO processing thread)
 ClientConnectAttempts = 4
 # time while client stays inactive, after this time is off (in seconds) client will be disconneced by server
 ClientInactivityTime = 120
 # timeout for BeginAccept in milliseconds
 ClientConnectTimeout = 1000
 # number of attempts in a row to get data from client
 ClientReadAttempts = 8
 # timeout in milliseconds on every read attemp 
 ReadTimeout = 200
 # timeout in milliseconds for server to shutdown, close all opened resources
 ServerCloseTimeout = 2000
 # timeout in milliseconds to complete write operation
 WriteTimeout = 1000 

`

6 CONTRIBUTORS

 EvilLord666 aka Ushakov Michael
 KatanaZZZ aka Anonymous
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].