From 7d9b735caaf15161c72303ba40ad8312375fdbd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Fri, 24 Oct 2025 17:15:51 +0800
Subject: [PATCH 01/15] update(touchsocket):version to 4.0.0-rc.2
---
.../touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj | 4 ++--
.../src/TouchSocketWebApi/TouchSocketWebApi.csproj | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
index 1b9d682382f..af57847b787 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
@@ -10,8 +10,8 @@
-
-
+
+
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
index 9067bb77f51..e78bdb62db6 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
@@ -9,7 +9,7 @@
-
-
+
+
From 8e085d39c153f874448c2a13317828373ede9cfd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Sun, 26 Oct 2025 22:10:56 +0800
Subject: [PATCH 02/15] update(touchsocket):version to 4.0.0-rc.5
---
.../touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj | 4 ++--
.../src/TouchSocketWebApi/TouchSocketWebApi.csproj | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
index af57847b787..b09d51fff00 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
@@ -10,8 +10,8 @@
-
-
+
+
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
index e78bdb62db6..572563f16bb 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
@@ -9,7 +9,7 @@
-
-
+
+
From cc8cbae5401a8c29be59326904c39e10046e50b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Thu, 30 Oct 2025 14:05:30 +0800
Subject: [PATCH 03/15] optimize(touchsocket):scheduler
---
.../CSharp/touchsocket/src/TouchSocketHttp/Program.cs | 6 ------
.../CSharp/touchsocket/src/TouchSocketWebApi/Program.cs | 6 ------
2 files changed, 12 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
index c54ff87c76e..125284cd970 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
@@ -15,12 +15,6 @@ private static async Task Main(string[] args)
await service.SetupAsync(new TouchSocketConfig()
.SetListenIPHosts(port)
- .SetNoDelay(true)
- .SetTransportOption(options =>
- {
- options.ReceivePipeOptions = TransportOption.CreateSchedulerOptimizedPipeOptions();
- options.SendPipeOptions = TransportOption.CreateSchedulerOptimizedPipeOptions();
- })
.SetMaxCount(1000000)
.ConfigureContainer(a =>
{
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
index 66d4c955f40..26cdfb935fd 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
@@ -18,12 +18,6 @@ public static void Main(string[] args)
builder.Services.AddServiceHostedService(config =>
{
config.SetListenIPHosts(8080)
- .SetNoDelay(true)
- .SetTransportOption(options =>
- {
- options.ReceivePipeOptions = TransportOption.CreateSchedulerOptimizedPipeOptions();
- options.SendPipeOptions = TransportOption.CreateSchedulerOptimizedPipeOptions();
- })
.SetMaxCount(1000000)
.ConfigureContainer(a =>
{
From 9721dd5e2018712952af036965ccaf9f0938b6d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Fri, 31 Oct 2025 13:11:21 +0800
Subject: [PATCH 04/15] Performance (TouchSocketHttp, TouchSocketWebApi):
Enable server garbage collection
---
.../touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj | 1 +
.../touchsocket/src/TouchSocketHttp31/TouchSocketHttp31.csproj | 2 +-
.../touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj | 1 +
.../src/TouchSocketWebApi31/TouchSocketWebApi31.csproj | 2 +-
4 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
index b09d51fff00..e550d0eedb6 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
@@ -5,6 +5,7 @@
enable
Exe
enable
+ true
dotnet-TouchSocketWebApi-987c185f-10b1-452b-beb6-47d798a5a131
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp31/TouchSocketHttp31.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttp31/TouchSocketHttp31.csproj
index 41261ace4f9..8f8a2d69035 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp31/TouchSocketHttp31.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp31/TouchSocketHttp31.csproj
@@ -7,8 +7,8 @@
enable
true
- dotnet-TouchSocketWebApi-987c185f-10b1-455b-beb6-47d798a5a131
true
+ dotnet-TouchSocketWebApi-987c185f-10b1-455b-beb6-47d798a5a131
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
index 572563f16bb..0a0fbc559c3 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
@@ -4,6 +4,7 @@
net9.0
enable
enable
+ true
dotnet-WorkerService1-19b37b17-6043-4334-ad9a-9e0e3c670da3
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi31/TouchSocketWebApi31.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi31/TouchSocketWebApi31.csproj
index 80742a45b17..d385bc8caed 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi31/TouchSocketWebApi31.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi31/TouchSocketWebApi31.csproj
@@ -6,8 +6,8 @@
enable
true
- dotnet-TouchSocketWebApi-987c185f-10b1-452b-beb7-47d798a5a131
true
+ dotnet-TouchSocketWebApi-987c185f-10b1-452b-beb7-47d798a5a131
From 35e5e5bcc09b42650f5ebcde0a42ed9dc6b1e761 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Sat, 1 Nov 2025 09:39:53 +0800
Subject: [PATCH 05/15] update(touchsocket):version to 4.0.0-rc.15
---
.../touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj | 4 ++--
.../src/TouchSocketWebApi/TouchSocketWebApi.csproj | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
index e550d0eedb6..74caaf7a658 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
@@ -11,8 +11,8 @@
-
-
+
+
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
index 0a0fbc559c3..1319cf14650 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
@@ -10,7 +10,7 @@
-
-
+
+
From 0606cc399132bc6bb96acff298cbbe6980129564 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Mon, 10 Nov 2025 14:39:50 +0800
Subject: [PATCH 06/15] update(touchsocket):version to 4.0.0-rc42
---
frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs | 4 ++++
.../touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj | 4 ++--
.../CSharp/touchsocket/src/TouchSocketWebApi/Program.cs | 4 ++++
.../src/TouchSocketWebApi/TouchSocketWebApi.csproj | 4 ++--
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
index 125284cd970..d08469401a0 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
@@ -16,6 +16,10 @@ private static async Task Main(string[] args)
await service.SetupAsync(new TouchSocketConfig()
.SetListenIPHosts(port)
.SetMaxCount(1000000)
+ .SetTransportOption(options =>
+ {
+ options.BufferOnDemand = false;
+ })
.ConfigureContainer(a =>
{
a.AddConsoleLogger();
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
index 74caaf7a658..136efe0b201 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
@@ -11,8 +11,8 @@
-
-
+
+
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
index 26cdfb935fd..71b8bc6a089 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
@@ -19,6 +19,10 @@ public static void Main(string[] args)
{
config.SetListenIPHosts(8080)
.SetMaxCount(1000000)
+ .SetTransportOption(options =>
+ {
+ options.BufferOnDemand = false;
+ })
.ConfigureContainer(a =>
{
a.AddConsoleLogger();
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
index 1319cf14650..a6ea669e926 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
@@ -10,7 +10,7 @@
-
-
+
+
From a95d6a54efaa4bbc389ed36d36f228527984f2ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Tue, 11 Nov 2025 22:32:00 +0800
Subject: [PATCH 07/15] =?UTF-8?q?=E9=87=8D=E6=9E=84(Program):=20=E6=98=BE?=
=?UTF-8?q?=E5=BC=8F=E6=8C=87=E5=AE=9A=E5=8F=98=E9=87=8F=E7=B1=BB=E5=9E=8B?=
=?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
显式指定变量类型以提高代码可读性和类型安全性
修改命名空间为 `TouchSocketHttp`
将 `options.BufferOnDemand` 默认值从 `false` 修改为 `true`
调整 `SetTransportOption` 和 `ApiServer` 中的相关代码
---
.../CSharp/touchsocket/src/TouchSocketHttp/Program.cs | 4 ++--
.../CSharp/touchsocket/src/TouchSocketWebApi/Program.cs | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
index d08469401a0..d77a1b3249d 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
@@ -10,7 +10,7 @@ public class Program
{
private static async Task Main(string[] args)
{
- var port = 8080;
+ int port = 8080;
var service = new MyHttpService();
await service.SetupAsync(new TouchSocketConfig()
@@ -18,7 +18,7 @@ await service.SetupAsync(new TouchSocketConfig()
.SetMaxCount(1000000)
.SetTransportOption(options =>
{
- options.BufferOnDemand = false;
+ options.BufferOnDemand = true;
})
.ConfigureContainer(a =>
{
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
index 71b8bc6a089..a7c9e6dcafe 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
@@ -21,7 +21,7 @@ public static void Main(string[] args)
.SetMaxCount(1000000)
.SetTransportOption(options =>
{
- options.BufferOnDemand = false;
+ options.BufferOnDemand = true;
})
.ConfigureContainer(a =>
{
@@ -49,7 +49,7 @@ public static void Main(string[] args)
});
});
- var host = builder.Build();
+ IHost host = builder.Build();
host.Run();
}
}
@@ -64,7 +64,7 @@ public partial class ApiServer : SingletonRpcServer
[WebApi(Method = HttpMethodType.Get)]
public async Task Plaintext(IWebApiCallContext callContext)
{
- var response = callContext.HttpContext.Response;
+ HttpResponse response = callContext.HttpContext.Response;
response.SetStatus(200, "ok");
response.Content = m_contentPlaintext;
await response.AnswerAsync().ConfigureAwait(false);
From 7dfc4b30637e1f2eedb16708f71d32ca9b9a4581 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Tue, 11 Nov 2025 23:20:46 +0800
Subject: [PATCH 08/15] =?UTF-8?q?=E4=BC=98=E5=8C=96(csproj):=20=E5=8D=87?=
=?UTF-8?q?=E7=BA=A7TouchSocket=E5=8C=85=E7=89=88=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
在TouchSocketHttp.csproj和TouchSocketWebApi.csproj中,将TouchSocket.Hosting和TouchSocket.WebApi的包引用版本从4.0.0-rc.42升级到4.0.0-rc.44,以修复错误、提高性能或增加新功能
---
.../touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj | 4 ++--
.../src/TouchSocketWebApi/TouchSocketWebApi.csproj | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
index 136efe0b201..ea6f43327a0 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
@@ -11,8 +11,8 @@
-
-
+
+
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
index a6ea669e926..d90651bb648 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
@@ -10,7 +10,7 @@
-
-
+
+
From a171b3ee4f241b881d4f52d4fbfd2385e5b24dfa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Fri, 14 Nov 2025 13:21:52 +0800
Subject: [PATCH 09/15] =?UTF-8?q?Add(TouchSocket)=EF=BC=9Aplatform=20test?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
frameworks/CSharp/touchsocket/Benchmarks.sln | 8 +-
.../src/TouchSocketHttp/Program.cs | 3 +-
.../src/TouchSocketHttpPlatform/DateHeader.cs | 73 +++++
.../src/TouchSocketHttpPlatform/MyServer.cs | 24 ++
.../MyTcpSessionClientBase.cs | 299 ++++++++++++++++++
.../src/TouchSocketHttpPlatform/Program.cs | 29 ++
.../TouchSocketHttpPlatform.csproj | 13 +
.../src/TouchSocketWebApi/Program.cs | 3 +-
8 files changed, 447 insertions(+), 5 deletions(-)
create mode 100644 frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/DateHeader.cs
create mode 100644 frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyServer.cs
create mode 100644 frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyTcpSessionClientBase.cs
create mode 100644 frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
create mode 100644 frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/TouchSocketHttpPlatform.csproj
diff --git a/frameworks/CSharp/touchsocket/Benchmarks.sln b/frameworks/CSharp/touchsocket/Benchmarks.sln
index 6f164942105..8d41045e044 100644
--- a/frameworks/CSharp/touchsocket/Benchmarks.sln
+++ b/frameworks/CSharp/touchsocket/Benchmarks.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
-VisualStudioVersion = 18.0.11109.219 d18.0-oob
+VisualStudioVersion = 18.0.11109.219
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TouchSocketWebApi", "src\TouchSocketWebApi\TouchSocketWebApi.csproj", "{6BD9363A-D77F-5D90-8444-2BC37495C920}"
EndProject
@@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TouchSocketHttp31", "src\To
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TouchSocketWebApi31", "src\TouchSocketWebApi31\TouchSocketWebApi31.csproj", "{6B6A57CE-1F69-FA6E-7458-0A4B6AB60683}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TouchSocketHttpPlatform", "src\TouchSocketHttpPlatform\TouchSocketHttpPlatform.csproj", "{BC320C24-941D-2109-FBC8-92780569BBA4}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +35,10 @@ Global
{6B6A57CE-1F69-FA6E-7458-0A4B6AB60683}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B6A57CE-1F69-FA6E-7458-0A4B6AB60683}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B6A57CE-1F69-FA6E-7458-0A4B6AB60683}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BC320C24-941D-2109-FBC8-92780569BBA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BC320C24-941D-2109-FBC8-92780569BBA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BC320C24-941D-2109-FBC8-92780569BBA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BC320C24-941D-2109-FBC8-92780569BBA4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
index d77a1b3249d..baa00f9da87 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/Program.cs
@@ -1,7 +1,6 @@
using System.Text;
using TouchSocket.Core;
using TouchSocket.Http;
-using TouchSocket.Sockets;
using HttpContent = TouchSocket.Http.HttpContent;
namespace TouchSocketHttp;
@@ -18,7 +17,7 @@ await service.SetupAsync(new TouchSocketConfig()
.SetMaxCount(1000000)
.SetTransportOption(options =>
{
- options.BufferOnDemand = true;
+ options.BufferOnDemand = false;
})
.ConfigureContainer(a =>
{
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/DateHeader.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/DateHeader.cs
new file mode 100644
index 00000000000..0adc6ef751b
--- /dev/null
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/DateHeader.cs
@@ -0,0 +1,73 @@
+// ------------------------------------------------------------------------------
+// 此代码版权(除特别声明或在XREF结尾的命名空间的代码)归作者本人若汝棋茗所有
+// 源代码使用协议遵循本仓库的开源协议及附加协议,若本仓库没有设置,则按MIT开源协议授权
+// CSDN博客:https://blog.csdn.net/qq_40374647
+// 哔哩哔哩视频:https://space.bilibili.com/94253567
+// Gitee源代码仓库:https://gitee.com/RRQM_Home
+// Github源代码仓库:https://github.com/RRQM
+// API首页:https://touchsocket.net/
+// 交流QQ群:234762506
+// 感谢您的下载和使用
+// ------------------------------------------------------------------------------
+
+using System.Buffers.Text;
+using System.Diagnostics;
+using TouchSocket.Core;
+using TouchSocket.Sockets;
+
+namespace HttpServerLinePerformanceConsoleApp;
+
+internal static class DateHeader
+{
+ private const int dateTimeRLength = 29;
+ private const int prefixLength = 6; // "Date: ".Length is 6 in bytes for ASCII
+ private const int suffixIndex = dateTimeRLength + prefixLength;
+
+ // Wed, 14 Mar 2018 14:20:00 GMT
+ private const int suffixLength = 2; // crlf
+ private static readonly Timer s_timer = new((s) =>
+ {
+ SetDateValues(DateTimeOffset.UtcNow);
+ }, null, 1000, 1000);
+
+ private static byte[] s_headerBytesMaster = new byte[prefixLength + dateTimeRLength + 2 * suffixLength];
+ private static byte[] s_headerBytesScratch = new byte[prefixLength + dateTimeRLength + 2 * suffixLength];
+
+ static DateHeader()
+ {
+ var utf8 = "Date: "u8;
+
+ utf8.CopyTo(s_headerBytesMaster);
+ utf8.CopyTo(s_headerBytesScratch);
+ s_headerBytesMaster[suffixIndex] = (byte)'\r';
+ s_headerBytesMaster[suffixIndex + 1] = (byte)'\n';
+ s_headerBytesMaster[suffixIndex + 2] = (byte)'\r';
+ s_headerBytesMaster[suffixIndex + 3] = (byte)'\n';
+ s_headerBytesScratch[suffixIndex] = (byte)'\r';
+ s_headerBytesScratch[suffixIndex + 1] = (byte)'\n';
+ s_headerBytesScratch[suffixIndex + 2] = (byte)'\r';
+ s_headerBytesScratch[suffixIndex + 3] = (byte)'\n';
+
+ SetDateValues(DateTimeOffset.UtcNow);
+ SyncDateTimer();
+ }
+
+ public static ReadOnlySpan HeaderBytes => s_headerBytesMaster;
+
+ public static void SyncDateTimer()
+ {
+ s_timer.Change(1000, 1000);
+ }
+ private static void SetDateValues(DateTimeOffset value)
+ {
+ lock (s_headerBytesScratch)
+ {
+ if (!Utf8Formatter.TryFormat(value, s_headerBytesScratch.AsSpan(prefixLength), out var written, 'R'))
+ {
+ throw new Exception("date time format failed");
+ }
+ Debug.Assert(written == dateTimeRLength);
+ (s_headerBytesScratch, s_headerBytesMaster) = (s_headerBytesMaster, s_headerBytesScratch);
+ }
+ }
+}
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyServer.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyServer.cs
new file mode 100644
index 00000000000..814da3397d3
--- /dev/null
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyServer.cs
@@ -0,0 +1,24 @@
+// ------------------------------------------------------------------------------
+// 此代码版权(除特别声明或在XREF结尾的命名空间的代码)归作者本人若汝棋茗所有
+// 源代码使用协议遵循本仓库的开源协议及附加协议,若本仓库没有设置,则按MIT开源协议授权
+// CSDN博客:https://blog.csdn.net/qq_40374647
+// 哔哩哔哩视频:https://space.bilibili.com/94253567
+// Gitee源代码仓库:https://gitee.com/RRQM_Home
+// Github源代码仓库:https://github.com/RRQM
+// API首页:https://touchsocket.net/
+// 交流QQ群:234762506
+// 感谢您的下载和使用
+// ------------------------------------------------------------------------------
+
+using TouchSocket.Sockets;
+
+namespace HttpServerLinePerformanceConsoleApp;
+
+internal sealed class MyServer : TcpService
+{
+ ///
+ protected override MyTcpSessionClientBase NewClient()
+ {
+ return new MyTcpSessionClientBase();
+ }
+}
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyTcpSessionClientBase.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyTcpSessionClientBase.cs
new file mode 100644
index 00000000000..b81e0d9cfb5
--- /dev/null
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyTcpSessionClientBase.cs
@@ -0,0 +1,299 @@
+// ------------------------------------------------------------------------------
+// 此代码版权(除特别声明或在XREF结尾的命名空间的代码)归作者本人若汝棋茗所有
+// 源代码使用协议遵循本仓库的开源协议及附加协议,若本仓库没有设置,则按MIT开源协议授权
+// CSDN博客:https://blog.csdn.net/qq_40374647
+// 哔哩哔哩视频:https://space.bilibili.com/94253567
+// Gitee源代码仓库:https://gitee.com/RRQM_Home
+// Github源代码仓库:https://github.com/RRQM
+// API首页:https://touchsocket.net/
+// 交流QQ群:234762506
+// 感谢您的下载和使用
+// ------------------------------------------------------------------------------
+
+using System.Buffers;
+using System.IO.Pipelines;
+using System.Runtime.CompilerServices;
+using TouchSocket.Sockets;
+
+namespace HttpServerLinePerformanceConsoleApp;
+
+///
+/// 路由类型
+///
+internal enum RouteType
+{
+ ///
+ /// 未知路由
+ ///
+ Unknown,
+
+ ///
+ /// 纯文本路由
+ ///
+ Plaintext,
+
+ ///
+ /// JSON路由
+ ///
+ Json
+}
+
+internal sealed class MyTcpSessionClientBase : TcpSessionClient
+{
+ #region Paths
+ public static ReadOnlySpan Json => "/json"u8;
+ public static ReadOnlySpan Plaintext => "/plaintext"u8;
+ #endregion
+
+
+ private static ReadOnlySpan PlainTextBody => "Hello, World!"u8;
+ private static ReadOnlySpan JsonBody => "{\"message\":\"Hello, World!\"}"u8;
+
+ private static ReadOnlySpan PlaintextPreamble =>
+ "HTTP/1.1 200 OK\r\n"u8 +
+ "Server: T\r\n"u8 +
+ "Content-Type: text/plain\r\n"u8 +
+ "Content-Length: 13\r\n"u8;
+
+ private static ReadOnlySpan JsonPreamble =>
+ "HTTP/1.1 200 OK\r\n"u8 +
+ "Server: T\r\n"u8 +
+ "Content-Type: application/json\r\n"u8 +
+ "Content-Length: 27\r\n"u8;
+
+ protected override async Task ReceiveLoopAsync(ITransport transport)
+ {
+ var pipeReader = transport.Reader;
+ var pipeWriter = transport.Writer;
+
+ while (true)
+ {
+ var readResult = await pipeReader.ReadAsync();
+ var bufferSequence = readResult.Buffer;
+
+ var totalConsumed = ProcessRequests(bufferSequence, pipeWriter, out var responseCount);
+
+ if (responseCount > 0)
+ {
+ await pipeWriter.FlushAsync();
+ }
+
+ if (totalConsumed > 0)
+ {
+ pipeReader.AdvanceTo(bufferSequence.GetPosition(totalConsumed));
+ }
+ else
+ {
+ pipeReader.AdvanceTo(bufferSequence.Start, bufferSequence.End);
+ }
+
+ if (readResult.IsCompleted)
+ {
+ break;
+ }
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static long ProcessRequests(ReadOnlySequence buffer, PipeWriter writer, out int responseCount)
+ {
+ var seqReader = new SequenceReader(buffer);
+ var totalConsumed = 0L;
+ responseCount = 0;
+
+ while (!seqReader.End)
+ {
+ var startConsumed = seqReader.Consumed;
+
+ // 请求行
+ if (!TryReadLine(ref seqReader, out var requestLineLength))
+ {
+ // 请求行不完整,不消费任何数据
+ break;
+ }
+
+ var requestLineConsumed = requestLineLength + 2;
+
+ // 读取Headers,直到空行;若不完整,回退并等待更多数据
+ var headersStartConsumed = seqReader.Consumed;
+ bool headersComplete = false;
+ while (!seqReader.End)
+ {
+ if (!TryReadLine(ref seqReader, out var headerLength))
+ {
+ // 回退到读取Headers前的位置,等待更多数据
+ var rewind = seqReader.Consumed - headersStartConsumed;
+ if (rewind > 0)
+ {
+ seqReader.Rewind(rewind);
+ }
+ headersComplete = false;
+ break;
+ }
+
+ if (headerLength == 0)
+ {
+ headersComplete = true;
+ break; // headers 结束
+ }
+ }
+
+ if (!headersComplete)
+ {
+ // 不完整,等待更多数据
+ break;
+ }
+
+ // 解析URL - 直接在原始位置解析,避免Slice
+ var routeType = ParseUrlFast(buffer.Slice(startConsumed), requestLineConsumed);
+
+ // 计算本次消费的字节数
+ var consumed = seqReader.Consumed - startConsumed;
+ totalConsumed += consumed;
+
+ // 写入响应
+ WriteResponseSync(writer, routeType);
+ responseCount++;
+ }
+
+ return totalConsumed;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static void WriteResponseSync(PipeWriter writer, RouteType routeType)
+ {
+ switch (routeType)
+ {
+ case RouteType.Plaintext:
+ writer.Write(PlaintextPreamble);
+ writer.Write(DateHeader.HeaderBytes);
+ writer.Write(PlainTextBody);
+ break;
+ case RouteType.Json:
+ writer.Write(JsonPreamble);
+ writer.Write(DateHeader.HeaderBytes);
+ writer.Write(JsonBody);
+ break;
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static bool TryReadLine(ref SequenceReader reader, out long length)
+ {
+ var start = reader.Consumed;
+
+ while (!reader.End)
+ {
+ if (reader.TryRead(out var b))
+ {
+ if (b == '\r')
+ {
+ // 查看是否有'\n',若暂不可用则回退并判定不完整
+ if (!reader.TryPeek(out var next))
+ {
+ // 回退已读取的'\r'
+ reader.Rewind(1);
+ length = 0;
+ return false;
+ }
+ if (next == '\n')
+ {
+ // 消费'\n'并返回本行长度(不含CRLF)
+ reader.Advance(1);
+ length = reader.Consumed - start - 2;
+ return true;
+ }
+ }
+ }
+ }
+
+ length = 0;
+ return false;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ private static RouteType ParseUrlFast(ReadOnlySequence sequence, long requestLineLength)
+ {
+ var reader = new SequenceReader(sequence);
+
+ // 跳过方法
+ var spaceCount = 0;
+ var urlStart = 0L;
+ var urlEnd = 0L;
+
+ while (reader.Consumed < requestLineLength && !reader.End)
+ {
+ if (reader.TryRead(out var b))
+ {
+ if (b == ' ')
+ {
+ spaceCount++;
+ if (spaceCount == 1)
+ {
+ urlStart = reader.Consumed;
+ }
+ else if (spaceCount == 2)
+ {
+ urlEnd = reader.Consumed - 1;
+ break;
+ }
+ }
+ }
+ }
+
+ if (spaceCount < 2)
+ {
+ return RouteType.Unknown;
+ }
+
+ var urlLength = urlEnd - urlStart;
+
+ // 截取URL片段
+ var startPos = sequence.GetPosition(urlStart);
+ var urlSlice = sequence.Slice(startPos, urlLength);
+
+ // "/plaintext"
+ if (urlLength == Plaintext.Length)
+ {
+ if (urlSlice.IsSingleSegment)
+ {
+ if (urlSlice.FirstSpan.SequenceEqual(Plaintext))
+ {
+ return RouteType.Plaintext;
+ }
+ }
+ else
+ {
+ Span tmp = stackalloc byte[(int)urlLength];
+ urlSlice.CopyTo(tmp);
+ if (tmp.SequenceEqual(Plaintext))
+ {
+ return RouteType.Plaintext;
+ }
+ }
+ }
+ // "/json"
+ else if (urlLength == Json.Length)
+ {
+ if (urlSlice.IsSingleSegment)
+ {
+ if (urlSlice.FirstSpan.SequenceEqual(Json))
+ {
+ return RouteType.Json;
+ }
+ }
+ else
+ {
+ Span tmp = stackalloc byte[(int)urlLength];
+ urlSlice.CopyTo(tmp);
+ if (tmp.SequenceEqual(Json))
+ {
+ return RouteType.Json;
+ }
+ }
+ }
+
+ return RouteType.Unknown;
+ }
+}
+
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
new file mode 100644
index 00000000000..36803c1bab0
--- /dev/null
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
@@ -0,0 +1,29 @@
+// ------------------------------------------------------------------------------
+// 此代码版权(除特别声明或在XREF结尾的命名空间的代码)归作者本人若汝棋茗所有
+// 源代码使用协议遵循本仓库的开源协议及附加协议,若本仓库没有设置,则按MIT开源协议授权
+// CSDN博客:https://blog.csdn.net/qq_40374647
+// 哔哩哔哩视频:https://space.bilibili.com/94253567
+// Gitee源代码仓库:https://gitee.com/RRQM_Home
+// Github源代码仓库:https://github.com/RRQM
+// API首页:https://touchsocket.net/
+// 交流QQ群:234762506
+// 感谢您的下载和使用
+// ------------------------------------------------------------------------------
+
+using TouchSocket.Core;
+using TouchSocket.Sockets;
+
+namespace HttpServerLinePerformanceConsoleApp;
+
+internal class Program
+{
+ private static async Task Main(string[] args)
+ {
+ var server = new MyServer();
+ await server.StartAsync(8080);
+
+ Console.WriteLine("HTTP服务器已启动,端口: 8080");
+ Console.ReadKey();
+ server.SafeDispose();
+ }
+}
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/TouchSocketHttpPlatform.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/TouchSocketHttpPlatform.csproj
new file mode 100644
index 00000000000..9d1a4cf3475
--- /dev/null
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/TouchSocketHttpPlatform.csproj
@@ -0,0 +1,13 @@
+
+
+
+ Exe
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
index a7c9e6dcafe..4033ac03745 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/Program.cs
@@ -3,7 +3,6 @@
using TouchSocket.Core;
using TouchSocket.Http;
using TouchSocket.Rpc;
-using TouchSocket.Sockets;
using TouchSocket.WebApi;
using HttpContent = TouchSocket.Http.HttpContent;
@@ -21,7 +20,7 @@ public static void Main(string[] args)
.SetMaxCount(1000000)
.SetTransportOption(options =>
{
- options.BufferOnDemand = true;
+ options.BufferOnDemand = false;
})
.ConfigureContainer(a =>
{
From 29bd9c25ce00b12fcadd54195cc3d9af91b11f55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Fri, 14 Nov 2025 13:26:54 +0800
Subject: [PATCH 10/15] Add:Platform config
---
frameworks/CSharp/touchsocket/README.md | 35 +++++++++++++++++--
.../CSharp/touchsocket/benchmark_config.json | 19 ++++++++++
frameworks/CSharp/touchsocket/config.toml | 13 +++++++
.../touchsocket-httpplatform.dockerfile | 13 +++++++
4 files changed, 78 insertions(+), 2 deletions(-)
create mode 100644 frameworks/CSharp/touchsocket/touchsocket-httpplatform.dockerfile
diff --git a/frameworks/CSharp/touchsocket/README.md b/frameworks/CSharp/touchsocket/README.md
index 22524d6f70a..8a520d40eec 100644
--- a/frameworks/CSharp/touchsocket/README.md
+++ b/frameworks/CSharp/touchsocket/README.md
@@ -2,9 +2,40 @@
See [touchsocket](https://touchsocket.net/) for more information.
+## Variants Included
+
+* `touchsocket.webapi` (`TouchSocketWebApi`) – WebApi style.
+* `touchsocket.webapi31` (`TouchSocketWebApi31`) – WebApi targeting .NET 8.
+* `touchsocket.http` (`TouchSocketHttp`) – Minimal HTTP implementation.
+* `touchsocket.http31` (`TouchSocketHttp31`) – Minimal HTTP targeting .NET 8.
+* `touchsocket.httpplatform` (`TouchSocketHttpPlatform`) – High-performance custom pipeline-based HTTP server focusing on low-level parsing and zero-allocation response writing.
+
## Infrastructure Software Versions
-**Language**
+**Language / Runtime**
+
+* C# / .NET (8.0 & 9.0 depending on variant)
+
+## Endpoints
+
+All variants implement:
+
+* `/plaintext` – Returns a plain text "Hello, World!" response.
+* `/json` – Returns a JSON object `{"message": "Hello, World!"}`.
+
+The `httpplatform` variant manually parses request lines and headers via `System.IO.Pipelines` for maximum throughput.
+
+## Dockerfiles
+
+Each variant has a dedicated Dockerfile named:
+
+* `touchsocket.dockerfile` (webapi)
+* `touchsocket-webapi31.dockerfile`
+* `touchsocket-http.dockerfile`
+* `touchsocket-http31.dockerfile`
+* `touchsocket-httpplatform.dockerfile`
+
+## Notes
-* C# 8.0
+The `httpplatform` variant is intended for benchmarking raw server performance. It omits higher-level abstractions to reduce overhead.
diff --git a/frameworks/CSharp/touchsocket/benchmark_config.json b/frameworks/CSharp/touchsocket/benchmark_config.json
index 8aa1e953f59..86036458c9a 100644
--- a/frameworks/CSharp/touchsocket/benchmark_config.json
+++ b/frameworks/CSharp/touchsocket/benchmark_config.json
@@ -77,6 +77,25 @@
"display_name": "touchsocket.webapi31",
"notes": "",
"versus": "aspnetcore-mvc"
+ },
+ "httpplatform": {
+ "plaintext_url": "/plaintext",
+ "json_url": "/json",
+ "port": 8080,
+ "approach": "Realistic",
+ "classification": "Platform",
+ "database": "Postgres",
+ "framework": "touchsocket.httpplatform",
+ "language": "C#",
+ "orm": "Micro",
+ "platform": ".NET",
+ "flavor": "CoreCLR",
+ "webserver": "touchsocket",
+ "os": "Linux",
+ "database_os": "Linux",
+ "display_name": "touchsocket.httpplatform",
+ "notes": "High-performance custom pipeline-based implementation variant.",
+ "versus": "aspnetcore"
}
}
]
diff --git a/frameworks/CSharp/touchsocket/config.toml b/frameworks/CSharp/touchsocket/config.toml
index 9af10d4a486..0d06cb4e331 100644
--- a/frameworks/CSharp/touchsocket/config.toml
+++ b/frameworks/CSharp/touchsocket/config.toml
@@ -52,3 +52,16 @@ orm = "Raw"
platform = ".NET"
webserver = "touchsocket.webapi31"
versus = "aspcore-mvc"
+
+[httpplatform]
+urls.plaintext = "/plaintext"
+urls.json = "/json"
+approach = "Realistic"
+classification = "Micro"
+database = "Postgres"
+database_os = "Linux"
+os = "Linux"
+orm = "Raw"
+platform = ".NET"
+webserver = "touchsocket.httpplatform"
+versus = "aspcore"
diff --git a/frameworks/CSharp/touchsocket/touchsocket-httpplatform.dockerfile b/frameworks/CSharp/touchsocket/touchsocket-httpplatform.dockerfile
new file mode 100644
index 00000000000..c20b0434e76
--- /dev/null
+++ b/frameworks/CSharp/touchsocket/touchsocket-httpplatform.dockerfile
@@ -0,0 +1,13 @@
+FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
+WORKDIR /app
+COPY src/TouchSocketHttpPlatform .
+RUN dotnet publish -c Release -o out
+
+FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
+
+WORKDIR /app
+COPY --from=build /app/out ./
+
+EXPOSE 8080
+
+ENTRYPOINT ["dotnet", "TouchSocketHttpPlatform.dll"]
From 7c17394a9bd812d5dd023cf888b98d4b5e193a7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Fri, 14 Nov 2025 13:39:40 +0800
Subject: [PATCH 11/15] =?UTF-8?q?=E4=BC=98=E5=8C=96(Program.cs):=20?=
=?UTF-8?q?=E6=9B=BF=E6=8D=A2=20Console.ReadKey=20=E4=B8=BA=20Console.Read?=
=?UTF-8?q?Line?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
替换 Program.cs 文件中 Program 类的 Console.ReadKey 为 Console.ReadLine
更改目的是更方便地处理用户输入或与其他代码逻辑保持一致
---
.../CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
index 36803c1bab0..964e66696f4 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
@@ -23,7 +23,7 @@ private static async Task Main(string[] args)
await server.StartAsync(8080);
Console.WriteLine("HTTP服务器已启动,端口: 8080");
- Console.ReadKey();
+ Console.ReadLine();
server.SafeDispose();
}
}
From afc20ca59b2879e54b5fbdce7200807614d8f436 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Fri, 14 Nov 2025 13:55:05 +0800
Subject: [PATCH 12/15] =?UTF-8?q?=E4=BC=98=E5=8C=96:=20=E7=A7=BB=E9=99=A4?=
=?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=20ServerGarbageCollection?=
=?UTF-8?q?=20=E5=B1=9E=E6=80=A7=E5=B9=B6=E7=BB=9F=E4=B8=80=E5=91=BD?=
=?UTF-8?q?=E5=90=8D=E7=A9=BA=E9=97=B4=E4=B8=BA=20TouchSocketHttpPlatform?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj | 1 -
.../touchsocket/src/TouchSocketHttpPlatform/DateHeader.cs | 2 +-
.../CSharp/touchsocket/src/TouchSocketHttpPlatform/MyServer.cs | 2 +-
.../src/TouchSocketHttpPlatform/MyTcpSessionClientBase.cs | 2 +-
.../CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs | 2 +-
.../touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj | 1 -
6 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
index ea6f43327a0..b334fdf4ffa 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
@@ -5,7 +5,6 @@
enable
Exe
enable
- true
dotnet-TouchSocketWebApi-987c185f-10b1-452b-beb6-47d798a5a131
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/DateHeader.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/DateHeader.cs
index 0adc6ef751b..9f0049fc54d 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/DateHeader.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/DateHeader.cs
@@ -15,7 +15,7 @@
using TouchSocket.Core;
using TouchSocket.Sockets;
-namespace HttpServerLinePerformanceConsoleApp;
+namespace TouchSocketHttpPlatform;
internal static class DateHeader
{
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyServer.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyServer.cs
index 814da3397d3..714b8ff367b 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyServer.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyServer.cs
@@ -12,7 +12,7 @@
using TouchSocket.Sockets;
-namespace HttpServerLinePerformanceConsoleApp;
+namespace TouchSocketHttpPlatform;
internal sealed class MyServer : TcpService
{
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyTcpSessionClientBase.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyTcpSessionClientBase.cs
index b81e0d9cfb5..1b95c2ddd72 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyTcpSessionClientBase.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/MyTcpSessionClientBase.cs
@@ -15,7 +15,7 @@
using System.Runtime.CompilerServices;
using TouchSocket.Sockets;
-namespace HttpServerLinePerformanceConsoleApp;
+namespace TouchSocketHttpPlatform;
///
/// 路由类型
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
index 964e66696f4..a99e49a32d7 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
@@ -13,7 +13,7 @@
using TouchSocket.Core;
using TouchSocket.Sockets;
-namespace HttpServerLinePerformanceConsoleApp;
+namespace TouchSocketHttpPlatform;
internal class Program
{
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
index d90651bb648..a352b0de1b0 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
@@ -4,7 +4,6 @@
net9.0
enable
enable
- true
dotnet-WorkerService1-19b37b17-6043-4334-ad9a-9e0e3c670da3
From 00d64e34f597ea288f06cdf5cedca35b3a9832e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Fri, 14 Nov 2025 13:58:36 +0800
Subject: [PATCH 13/15] =?UTF-8?q?=E4=BC=98=E5=8C=96(Program):=20=E8=B0=83?=
=?UTF-8?q?=E6=95=B4HTTP=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=90=AF=E5=8A=A8?=
=?UTF-8?q?=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
重构服务器启动流程以支持更灵活的配置:
- 替换server.StartAsync(8080)为server.SetupAsync配置流程
- 配置监听端口、最大连接数及控制台日志记录器
- 删除server.SafeDispose,改为通过while(true)保持运行
- 删除直接调用Console.ReadLine的逻辑
---
.../src/TouchSocketHttpPlatform/Program.cs | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
index a99e49a32d7..95576ee70b5 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/Program.cs
@@ -20,10 +20,20 @@ internal class Program
private static async Task Main(string[] args)
{
var server = new MyServer();
- await server.StartAsync(8080);
+ await server.SetupAsync(new TouchSocketConfig()
+ .SetListenIPHosts(8080)
+ .SetMaxCount(1000000)
+ .ConfigureContainer(a =>
+ {
+ a.AddConsoleLogger();
+ }));
+ await server.StartAsync();
Console.WriteLine("HTTP服务器已启动,端口: 8080");
- Console.ReadLine();
- server.SafeDispose();
+
+ while (true)
+ {
+ Console.ReadLine();
+ }
}
}
From b59b6d9b3fbf27efd6738574264266bca199b07b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Mon, 17 Nov 2025 09:55:47 +0800
Subject: [PATCH 14/15] =?UTF-8?q?=E9=87=8D=E6=9E=84(project):=20=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=E9=A1=B9=E7=9B=AE=E4=BE=9D=E8=B5=96=E5=92=8CSDK?=
=?UTF-8?q?=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
更新 `TouchSocketHttp.csproj` 的项目 SDK 为 `Microsoft.NET.Sdk`,移除 `` 配置
移除 `Microsoft.Extensions.Hosting` 和 `TouchSocket.Hosting` 旧版本依赖,更新 `TouchSocket.WebApi` 至 `4.0.0-rc.46`
更新 `TouchSocketHttpPlatform.csproj` 中 `TouchSocket` 包版本至 `4.0.0-rc.46`
更新 `TouchSocketWebApi.csproj` 中 `TouchSocket.Hosting` 和 `TouchSocket.WebApi` 包版本至 `4.0.0-rc.46`
---
.../touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj | 7 ++-----
.../TouchSocketHttpPlatform/TouchSocketHttpPlatform.csproj | 2 +-
.../src/TouchSocketWebApi/TouchSocketWebApi.csproj | 4 ++--
3 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
index b334fdf4ffa..073c2d99413 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttp/TouchSocketHttp.csproj
@@ -1,17 +1,14 @@
-
+
net9.0
enable
Exe
enable
- dotnet-TouchSocketWebApi-987c185f-10b1-452b-beb6-47d798a5a131
-
-
-
+
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/TouchSocketHttpPlatform.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/TouchSocketHttpPlatform.csproj
index 9d1a4cf3475..8e9841293fc 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/TouchSocketHttpPlatform.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/TouchSocketHttpPlatform.csproj
@@ -8,6 +8,6 @@
-
+
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
index a352b0de1b0..909c2f984ee 100644
--- a/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketWebApi/TouchSocketWebApi.csproj
@@ -9,7 +9,7 @@
-
-
+
+
From c0e61e8426314d549b694c683ed3a3b4fe03f3fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8B=A5=E6=B1=9D=E6=A3=8B=E8=8C=97?= <505554090@qq.com>
Date: Mon, 17 Nov 2025 10:09:04 +0800
Subject: [PATCH 15/15] =?UTF-8?q?=E6=96=B0=E5=A2=9E(config):=20=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=20NuGet.Config=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
添加新的 NuGet.Config 文件,包含以下更改:
- 引入 XML 声明,版本为 1.0,编码为 UTF-8
- 在 `` 节点中定义 `` 节点
- 使用 `` 清除所有现有的包源配置
- 添加新的包源,键为 "NuGet",值为 "https://api.nuget.org/v3/index.json"
---
.../touchsocket/src/TouchSocketHttpPlatform/NuGet.Config | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/NuGet.Config
diff --git a/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/NuGet.Config b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/NuGet.Config
new file mode 100644
index 00000000000..f05d5867888
--- /dev/null
+++ b/frameworks/CSharp/touchsocket/src/TouchSocketHttpPlatform/NuGet.Config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+