Tcp Client Server rpc library with binary serialization. Protobuf and or custom serialization is supporting out-of-box.
TNT is supposed for being fast compact and easy to use library. Watch speed test results below.
To install TNT, run the following command in the Package Manager Console:
PM> Install-Package tnt
void main(){
var server = TntBuilder
.UseContract<IExampleContract, ExampleContract>()
.CreateTcpServer(IPAddress.Any, 12345);
server.StartListening();
Console.WriteLine("Type your messages:");
while (true) {
var message = Console.ReadLine();
using (var client = TntBuilder.UseContract<IExampleContract>()
.CreateTcpClientConnection(IPAddress.Loopback, 12345))
{
client.Contract.Send("Superman", message);
}
}
server.Close();
}
//contract
public interface IExampleContract {
[TntMessage(1)] void Send(string user, string message);
}
//contract implementation
public class ExampleContract : IExampleContract {
public void Send(string user, string message) {
Console.WriteLine($"[Server received:] {user} : {message}");
}
}
Other examples:
It's hard to name a single figure, otrageous overall TNT speed if you're not a marketer. There are many such numbers. All results are performed by local speed test
General speed results:
no serialization: 2.5 - 5 Gbit
protobuff serialization: 0.4 - 1 GBit
Output speed:
[Sending in "fire and forget" style]
Raw byte Array: up to 2300 megabytes/sec
String serialization: up to 830 megabytes/sec
Protobuff serialization: up to 120 megabytes/sec
Echo transaction speed:
[Send data and received its copy]
Raw byte Array: up to 300 megabytes/sec
String serialization: up to 188 megabytes/sec
Protobuff serialization: up to 47 megabytes/sec
Overheads:
Output localhost Delay: 9,06 microseconds
Output message overhead: 6 byte per message
Echo transaction localhost (IO) Delay: 34,87 microseconds
Echo transaction (I/O) overhead : 8/12 byte per message