TCPMaid 1.0.1

Additional Details

Failure to send a message causes an infinite loop and memory leak.

There is a newer version of this package available.
See the version list below for details.
dotnet add package TCPMaid --version 1.0.1                
NuGet\Install-Package TCPMaid -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TCPMaid" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TCPMaid --version 1.0.1                
#r "nuget: TCPMaid, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TCPMaid as a Cake Addin
#addin nuget:?package=TCPMaid&version=1.0.1

// Install TCPMaid as a Cake Tool
#tool nuget:?package=TCPMaid&version=1.0.1                

Icon

TCPMaid

An easy, powerful and lightweight TCP client/server in C#.

TCPMaid makes it easy to setup a robust client & server, send messages and requests, and provide your own SSL certificate.

Features

  • Easy client & server setup
  • Support for SSL encryption and certificates
  • Automatic serialisation of messages
  • Send requests and wait for a response
  • Automatic fragmentation of large messages
  • Support for IPv4 and IPv6

Dependencies

Example

public static void Server() {
    TCPMaidServer Server = new(5000);
    Server.OnConnect += OnConnect;

    Server.Start();
    
    void OnConnect(Connection Client) {
        Client.OnReceive += Message => OnReceive(Client, Message);
        
        Console.WriteLine("Hi, client!");
    }
    void OnReceive(Connection Client, Message Message) {
        if (Message is ExampleMessage ExampleMessage) {
            Console.WriteLine($"Received '{ExampleMessage.ExampleText}' from client!");
        }
    }
}
public static async void Client() {
    TCPMaidClient Client = new();

    await Client.ConnectAsync("localhost", 5000);
    Connection Connection = Client.Connection!;

    await Connection.SendAsync(new ExampleMessage("hello server!"));
}
public class ExampleMessage : Message {
    [JsonProperty] public readonly string ExampleText;
    
    public ExampleMessage(string example_text) {
        ExampleText = example_text;
    }
}
Output
Hi, client!
Received 'hello server!' from client!
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.