dmuka3.CS.Simple.TCP 1.0.5

dotnet add package dmuka3.CS.Simple.TCP --version 1.0.5                
NuGet\Install-Package dmuka3.CS.Simple.TCP -Version 1.0.5                
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="dmuka3.CS.Simple.TCP" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add dmuka3.CS.Simple.TCP --version 1.0.5                
#r "nuget: dmuka3.CS.Simple.TCP, 1.0.5"                
#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 dmuka3.CS.Simple.TCP as a Cake Addin
#addin nuget:?package=dmuka3.CS.Simple.TCP&version=1.0.5

// Install dmuka3.CS.Simple.TCP as a Cake Tool
#tool nuget:?package=dmuka3.CS.Simple.TCP&version=1.0.5                

dmuka3.CS.Simple.TCP

This library provides you to send/receive byte[] on tcp easily.

Nuget

Link : https://www.nuget.org/packages/dmuka3.CS.Simple.TCP/

Install-Package dmuka3.CS.Simple.TCP

Example 1

You have to know that this library can't be used without .net tcp libraries. We just added somethings to be more useful.

Firstly, what to use this library for? Only to send and to receive byte[] via tcp. But we will use a different protocol to use this library. Don't worry, it's too ordionary technique.

Protocol

// PACKAGE        = [1,2,3,4,5]
// PACKAGE LENGTH = 5

// TCP PACKAGE = [0, 0, 0, 5, 1, 2, 3, 4, 5]

I told you that it's too ordionary technique. We just added 4 byte(INT32) at beginning of package to get package length. After that, we will push the original package at the ending of package. Of course, we can't use this protocol to receive some datas from other services(HTTP, FTP, etc.). We can use this only personal purposes.

TcpListener server = new TcpListener(IPAddress.Any, 9875);
server.Start();

bool stopped = false;
bool test = false;

new Thread(() =>
{
    var client = server.AcceptTcpClient();
    var conn = new TCPClientConnection(client);

    conn.Send(Encoding.UTF8.GetBytes("HELLO_SERVER"));
    var msg = Encoding.UTF8.GetString(conn.Receive());
    if (msg == "HELLO_CLIENT")
        test = true;
    stopped = true;
}).Start();
new Thread(() =>
{
    var client = new TcpClient();
    client.Connect("127.0.0.1", 9875);
    var conn = new TCPClientConnection(client);
    var msg = Encoding.UTF8.GetString(conn.Receive());
    if (msg == "HELLO_SERVER")
        conn.Send(Encoding.UTF8.GetBytes("HELLO_CLIENT"));
    else
        stopped = true;
}).Start();

while (!stopped)
    Thread.Sleep(1);

server.Stop();

Assert.IsTrue(test);

Example 2

So we will do another example. That is to communication with RSA. It is almost same but has a only distinctive feature. This feature ise "StartDMUKA3RSA".

TcpListener server = new TcpListener(IPAddress.Any, 9875);
server.Start();

bool stopped = false;
bool test = false;

new Thread(() =>
{
    var client = server.AcceptTcpClient();
    var conn = new TCPClientConnection(client);
    conn.StartDMUKA3RSA(2048);

    conn.Send(Encoding.UTF8.GetBytes("HELLO_SERVER"));

    var msg = Encoding.UTF8.GetString(conn.Receive());
    if (msg == "HELLO_CLIENT")
        test = true;
    stopped = true;
}).Start();
new Thread(() =>
{
    var client = new TcpClient();
    client.Connect("127.0.0.1", 9875);

    var conn = new TCPClientConnection(client);
    conn.StartDMUKA3RSA(2048);

    var msg = Encoding.UTF8.GetString(conn.Receive());
    if (msg == "HELLO_SERVER")
        conn.Send(Encoding.UTF8.GetBytes("HELLO_CLIENT"));
    else
        stopped = true;
}).Start();

while (!stopped)
    Thread.Sleep(1);

server.Stop();

Assert.IsTrue(test);

But you must not forget a thing that you must start StartDMUKA3RSA at the same time both of client and server.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on dmuka3.CS.Simple.TCP:

Package Downloads
dmuka3.CS.Simple.RamDb

Package Description

dmuka3.CS.Simple.Queuing

Package Description

dmuka3.CS.Simple.RemoteIO

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 990 10/29/2019
1.0.4 468 10/29/2019
1.0.3 693 10/28/2019
1.0.2 970 10/26/2019
1.0.1 467 10/26/2019
1.0.0 471 10/26/2019