refactor: modify into client server model

This commit is contained in:
2026-05-20 12:08:12 -04:00
parent 0b677fd991
commit 3e6426c655
9 changed files with 59 additions and 7 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
DotnetSystemd/bin/** */bin/**
DotnetSystemd/obj/** */obj/**
.nuget-packages .nuget-packages
result result
+11
View File
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Client</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+1
View File
@@ -0,0 +1 @@
[]
+35
View File
@@ -0,0 +1,35 @@
using System.Net;
using System.Net.Sockets;
using var listener = new Socket(SocketType.Stream, ProtocolType.Tcp);
listener.Bind(new IPEndPoint(IPAddress.Loopback, 9000));
Console.WriteLine($"Listening on {listener.LocalEndPoint}");
listener.Listen();
while (true)
{
var connection = await listener.AcceptAsync();
_ = Task.Run(async () =>
{
var buffer = new byte[4096];
try
{
while (true)
{
int read = await connection.ReceiveAsync(buffer, SocketFlags.None);
if (read == 0) break;
await connection.SendAsync(buffer[..read], SocketFlags.None);
}
}
finally
{
connection.Dispose();
}
}
);
}
@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework> <TargetFramework>net10.0</TargetFramework>
<RootNamespace>dotnet_systemd</RootNamespace> <RootNamespace>Server</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
+5
View File
@@ -0,0 +1,5 @@
<Solution>
<Folder Name="/Server/">
<Project Path="Server/Server.csproj" />
</Folder>
</Solution>
+4 -4
View File
@@ -25,9 +25,9 @@
packages.default = pkgs.buildDotnetModule { packages.default = pkgs.buildDotnetModule {
pname = "dotnet-systemd"; pname = "dotnet-systemd";
version = "0.1.0"; version = "0.1.0";
src = ./DotnetSystemd; src = ./Server;
nugetDeps = ./DotnetSystemd/deps.json; nugetDeps = ./Server/deps.json;
dotnet-sdk = pkgs.dotnet-sdk_10; dotnet-sdk = pkgs.dotnet-sdk_10;
dotnet-runtime = dotnetRuntime; dotnet-runtime = dotnetRuntime;
@@ -42,8 +42,8 @@
mkdir -p $out/bin mkdir -p $out/bin
cp -r bin/Release/net10.0/* $out/bin/ cp -r bin/Release/net10.0/* $out/bin/
makeWrapper ${dotnetRuntime}/bin/dotnet $out/bin/dotnet-systemd \ makeWrapper ${dotnetRuntime}/bin/dotnet $out/bin/Server \
--add-flags "exec $out/bin/dotnet-systemd.dll" \ --add-flags "exec $out/bin/Server.dll" \
--prefix LD_LIBRARY_PATH : "${ --prefix LD_LIBRARY_PATH : "${
pkgs.lib.makeLibraryPath [ pkgs.lib.makeLibraryPath [
pkgs.stdenv.cc.cc.lib pkgs.stdenv.cc.cc.lib