Orion.Network.Tcp 0.9.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Orion.Network.Tcp --version 0.9.0
                    
NuGet\Install-Package Orion.Network.Tcp -Version 0.9.0
                    
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="Orion.Network.Tcp" Version="0.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Orion.Network.Tcp" Version="0.9.0" />
                    
Directory.Packages.props
<PackageReference Include="Orion.Network.Tcp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Orion.Network.Tcp --version 0.9.0
                    
#r "nuget: Orion.Network.Tcp, 0.9.0"
                    
#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.
#addin nuget:?package=Orion.Network.Tcp&version=0.9.0
                    
Install Orion.Network.Tcp as a Cake Addin
#tool nuget:?package=Orion.Network.Tcp&version=0.9.0
                    
Install Orion.Network.Tcp as a Cake Tool

Orion.Network.Tcp

NuGet Version License .NET

TCP implementation for the Orion IRC Server networking layer.

IRC is not dead, long live IRC!

About

Orion.Network.Tcp provides a concrete TCP implementation of the network transport abstractions defined in Orion.Network.Core. This library enables Orion IRC Server to communicate with clients over standard TCP connections, with support for both secure (SSL/TLS) and non-secure channels.

Installation

dotnet add package Orion.Network.Tcp

Or using the Package Manager Console:

Install-Package Orion.Network.Tcp

Key Features

  • TCP Transport: Implementation of INetworkTransport for TCP communication
  • SSL/TLS Support: Secure communication with SSL/TLS encryption
  • Session Management: Tracking and managing TCP client sessions
  • Performance Optimized: Efficient buffer handling and message parsing
  • Flexible Configuration: Support for various TCP server configurations
  • NetCoreServer Integration: Built on top of the high-performance NetCoreServer library

Components

The library includes several key components:

  • NonSecureTcpServer: TCP server implementation without encryption
  • SecureTcpServer: TCP server with SSL/TLS encryption
  • NonSecureTcpSession: Session handler for non-secure connections
  • SecureTcpSession: Session handler for secure connections

Examples

Registering TCP Transports with the Transport Manager

using System.Net;
using System.Security.Authentication;
using NetCoreServer;
using Orion.Core.Types;
using Orion.Network.Core.Interfaces.Services;
using Orion.Network.Tcp.Servers;

public class NetworkSetup
{
    private readonly INetworkTransportManager _transportManager;

    public NetworkSetup(INetworkTransportManager transportManager)
    {
        _transportManager = transportManager;
    }

    public async Task ConfigureNetworkAsync()
    {
        // Add a non-secure TCP server for client connections
        var server = new NonSecureTcpServer(
            ServerNetworkType.Clients,
            IPAddress.Parse("0.0.0.0"),
            6667
        );
        _transportManager.AddTransport(server);

        // Add a secure TCP server with SSL/TLS
        var certificate = X509Certificate2.CreateFromPemFile("server.crt", "server.key");
        var sslContext = new SslContext(SslProtocols.Tls13, certificate);

        var secureServer = new SecureTcpServer(
            ServerNetworkType.Clients,
            sslContext,
            IPAddress.Parse("0.0.0.0"),
            6697
        );
        _transportManager.AddTransport(secureServer);

        // Start all transports
        await _transportManager.StartAsync();
    }
}

Sending Messages to Clients

using System.Text;
using Orion.Network.Core.Interfaces.Services;

public class MessageSender
{
    private readonly INetworkTransportManager _transportManager;

    public MessageSender(INetworkTransportManager transportManager)
    {
        _transportManager = transportManager;
    }

    public async Task SendMessageAsync(string sessionId, string message)
    {
        byte[] data = Encoding.UTF8.GetBytes(message + "\r\n");

        // Check if session exists
        if (_transportManager.HasSession(sessionId))
        {
            // Send the message
            await _transportManager.SendAsync(sessionId, data);
        }
    }

    public async Task BroadcastAsync(string message)
    {
        byte[] data = Encoding.UTF8.GetBytes(message + "\r\n");

        // Get all sessions and send to each
        var sessions = _transportManager.GetAllSessions();
        foreach (var sessionId in sessions)
        {
            await _transportManager.SendAsync(sessionId, data);
        }
    }
}

Implementation Details

NonSecureTcpServer

The NonSecureTcpServer class implements INetworkTransport to provide non-encrypted TCP connectivity:

public class NonSecureTcpServer : TcpServer, INetworkTransport
{
    // INetworkTransport event handlers
    public event INetworkTransport.ClientConnectedHandler? ClientConnected;
    public event INetworkTransport.ClientDisconnectedHandler? ClientDisconnected;
    public event INetworkTransport.MessageReceivedHandler? MessageReceived;

    // Implementation details follow...
}

SecureTcpServer

The SecureTcpServer class provides SSL/TLS-encrypted TCP connectivity:

public class SecureTcpServer : SslServer, INetworkTransport
{
    // INetworkTransport event handlers
    public event INetworkTransport.ClientConnectedHandler? ClientConnected;
    public event INetworkTransport.ClientDisconnectedHandler? ClientDisconnected;
    public event INetworkTransport.MessageReceivedHandler? MessageReceived;

    // Implementation details follow...
}

Dependencies

  • Orion.Core: Core utilities and extensions
  • Orion.Network.Core: Networking abstractions
  • NetCoreServer: High-performance socket server library
  • Orion.Core: Core utilities and extensions
  • Orion.Core.Server: Server-side core functionality
  • Orion.Irc.Core: IRC protocol implementation
  • Orion.Network.Core: Networking abstractions

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.

Version Downloads Last updated
0.30.1 116 5/15/2025
0.30.0 124 5/13/2025
0.29.0 150 5/12/2025
0.28.4 122 5/12/2025
0.28.3 121 5/12/2025
0.28.2 129 5/12/2025
0.28.1 117 5/11/2025
0.28.0 49 5/10/2025
0.27.1 144 5/8/2025
0.27.0 120 5/8/2025
0.26.0 126 5/8/2025
0.25.2 126 5/8/2025
0.25.1 121 5/8/2025
0.25.0 136 5/8/2025
0.24.0 125 5/6/2025
0.23.0 125 5/6/2025
0.22.3 124 5/6/2025
0.22.2 133 5/5/2025
0.22.0 89 5/2/2025
0.21.0 86 5/2/2025
0.20.0 99 5/2/2025
0.19.1 99 5/2/2025
0.19.0 125 5/1/2025
0.18.1 123 5/1/2025
0.18.0 131 4/30/2025
0.17.0 134 4/29/2025
0.16.0 155 4/29/2025
0.15.0 136 4/28/2025
0.14.3 149 4/28/2025
0.14.2 147 4/28/2025
0.14.1 142 4/28/2025
0.14.0 147 4/28/2025
0.13.0 146 4/28/2025
0.12.3 137 4/28/2025
0.12.2 144 4/28/2025
0.12.1 154 4/28/2025
0.12.0 139 4/28/2025
0.11.1 150 4/28/2025
0.11.0 139 4/28/2025
0.10.0 144 4/28/2025
0.9.0 143 4/23/2025
0.8.0 153 4/23/2025
0.7.0 159 4/22/2025
0.6.1 138 4/22/2025
0.6.0 153 4/20/2025
0.5.0 149 4/20/2025
0.4.0 156 4/20/2025
0.3.0 82 4/19/2025
0.2.0 134 4/18/2025
0.1.10 157 4/18/2025
0.1.9 155 4/18/2025
0.1.8 154 4/18/2025
0.1.7 144 4/18/2025
0.1.6 157 4/18/2025
0.1.5 153 4/18/2025
0.1.4 158 4/18/2025
0.1.3 175 4/17/2025
0.1.2 186 4/17/2025