From d05f11fe0d09db9ce5a076fe9b4bc56f04f2ffb8 Mon Sep 17 00:00:00 2001 From: zhengle Date: Wed, 24 Aug 2022 11:34:45 +0800 Subject: [PATCH 1/2] support netstandard2.1 --- source/NetCoreServer/FileCache.cs | 2 +- source/NetCoreServer/HttpClient.cs | 2 +- source/NetCoreServer/HttpServer.cs | 2 +- source/NetCoreServer/HttpsClient.cs | 2 +- source/NetCoreServer/HttpsServer.cs | 2 +- source/NetCoreServer/NetCoreServer.csproj | 2 +- source/NetCoreServer/UdpClient.cs | 2 +- source/NetCoreServer/UdpServer.cs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/NetCoreServer/FileCache.cs b/source/NetCoreServer/FileCache.cs index e5f2814f..76681724 100644 --- a/source/NetCoreServer/FileCache.cs +++ b/source/NetCoreServer/FileCache.cs @@ -95,7 +95,7 @@ public bool Remove(string key) /// 'true' if the cache path was setup, 'false' if failed to setup the cache path public bool InsertPath(string path, string prefix = "/", string filter = "*.*", TimeSpan timeout = new TimeSpan(), InsertHandler handler = null) { - handler ??= (FileCache cache, string key, byte[] value, TimeSpan timespan) => cache.Add(key, value, timespan); + handler = handler ?? ((FileCache cache, string key, byte[] value, TimeSpan timespan) => cache.Add(key, value, timespan)); // Try to find and remove the previous path RemovePathInternal(path); diff --git a/source/NetCoreServer/HttpClient.cs b/source/NetCoreServer/HttpClient.cs index 29e827af..98b69c4d 100644 --- a/source/NetCoreServer/HttpClient.cs +++ b/source/NetCoreServer/HttpClient.cs @@ -259,7 +259,7 @@ public HttpClientEx(IPEndPoint endpoint) : base(endpoint) {} /// HTTP request Task public Task SendRequest(HttpRequest request, TimeSpan? timeout = null) { - timeout ??= TimeSpan.FromMinutes(1); + timeout = timeout ?? TimeSpan.FromMinutes(1); _tcs = new TaskCompletionSource(); Request = request; diff --git a/source/NetCoreServer/HttpServer.cs b/source/NetCoreServer/HttpServer.cs index 419f04c9..363aea3a 100644 --- a/source/NetCoreServer/HttpServer.cs +++ b/source/NetCoreServer/HttpServer.cs @@ -47,7 +47,7 @@ public class HttpServer : TcpServer /// Refresh cache timeout (default is 1 hour) public void AddStaticContent(string path, string prefix = "/", string filter = "*.*", TimeSpan? timeout = null) { - timeout ??= TimeSpan.FromHours(1); + timeout = timeout ?? TimeSpan.FromHours(1); bool Handler(FileCache cache, string key, byte[] value, TimeSpan timespan) { diff --git a/source/NetCoreServer/HttpsClient.cs b/source/NetCoreServer/HttpsClient.cs index 2ba4006e..c8bb203d 100644 --- a/source/NetCoreServer/HttpsClient.cs +++ b/source/NetCoreServer/HttpsClient.cs @@ -268,7 +268,7 @@ public HttpsClientEx(SslContext context, IPEndPoint endpoint) : base(context, en /// HTTP request Task public Task SendRequest(HttpRequest request, TimeSpan? timeout = null) { - timeout ??= TimeSpan.FromMinutes(1); + timeout = timeout ?? TimeSpan.FromMinutes(1); _tcs = new TaskCompletionSource(); Request = request; diff --git a/source/NetCoreServer/HttpsServer.cs b/source/NetCoreServer/HttpsServer.cs index c7eee723..020be812 100644 --- a/source/NetCoreServer/HttpsServer.cs +++ b/source/NetCoreServer/HttpsServer.cs @@ -51,7 +51,7 @@ public class HttpsServer : SslServer /// Refresh cache timeout (default is 1 hour) public void AddStaticContent(string path, string prefix = "/", string filter = "*.*", TimeSpan? timeout = null) { - timeout ??= TimeSpan.FromHours(1); + timeout = timeout ?? TimeSpan.FromHours(1); bool Handler(FileCache cache, string key, byte[] value, TimeSpan timespan) { diff --git a/source/NetCoreServer/NetCoreServer.csproj b/source/NetCoreServer/NetCoreServer.csproj index b17b36a4..0ee01b3f 100644 --- a/source/NetCoreServer/NetCoreServer.csproj +++ b/source/NetCoreServer/NetCoreServer.csproj @@ -1,7 +1,6 @@  - net6.0 6.5.0.0 Ivan Shynkarenka Copyright (c) 2019-2022 Ivan Shynkarenka @@ -10,6 +9,7 @@ MIT https://github.com/chronoxor/NetCoreServer async;client;server;tcp;udp;ssl;tls;http;https;websocket;low latency;performance + net6.0;netstandard2.1 diff --git a/source/NetCoreServer/UdpClient.cs b/source/NetCoreServer/UdpClient.cs index 76f83659..26bfe73b 100644 --- a/source/NetCoreServer/UdpClient.cs +++ b/source/NetCoreServer/UdpClient.cs @@ -457,7 +457,7 @@ public virtual long Send(EndPoint endpoint, ReadOnlySpan buffer) try { // Sent datagram to the server - int sent = Socket.SendTo(buffer, SocketFlags.None, endpoint); + int sent = Socket.SendTo(buffer.ToArray(), SocketFlags.None, endpoint); if (sent > 0) { // Update statistic diff --git a/source/NetCoreServer/UdpServer.cs b/source/NetCoreServer/UdpServer.cs index 250ed5b3..6b3de045 100644 --- a/source/NetCoreServer/UdpServer.cs +++ b/source/NetCoreServer/UdpServer.cs @@ -473,7 +473,7 @@ public virtual long Send(EndPoint endpoint, ReadOnlySpan buffer) try { // Sent datagram to the client - int sent = Socket.SendTo(buffer, SocketFlags.None, endpoint); + int sent = Socket.SendTo(buffer.ToArray(), SocketFlags.None, endpoint); if (sent > 0) { // Update statistic From 489377dcd285d5147db043be165c198e855c728e Mon Sep 17 00:00:00 2001 From: Jennal Date: Thu, 27 Jul 2023 23:48:57 +0800 Subject: [PATCH 2/2] change description & upload to nuget --- source/NetCoreServer/NetCoreServer.csproj | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/NetCoreServer/NetCoreServer.csproj b/source/NetCoreServer/NetCoreServer.csproj index cf6a7f4e..dfb4a8da 100644 --- a/source/NetCoreServer/NetCoreServer.csproj +++ b/source/NetCoreServer/NetCoreServer.csproj @@ -2,12 +2,15 @@ 7.0.0.0 - Ivan Shynkarenka - Copyright (c) 2019-2022 Ivan Shynkarenka - https://github.com/chronoxor/NetCoreServer - Ultra fast and low latency asynchronous socket server & client C# .NET Core library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution + GoPlay.NetCoreServer + Jennal + Copyright © What2d Ltd. 2023 + https://github.com/jennal/NetCoreServer + Fork from [https://github.com/chronoxor/NetCoreServer](https://github.com/chronoxor/NetCoreServer), make it support .NET Standard 2.1 + +Ultra fast and low latency asynchronous socket server & client C# .NET Core library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution MIT - https://github.com/chronoxor/NetCoreServer + https://github.com/jennal/NetCoreServer async;client;server;tcp;udp;ssl;tls;http;https;websocket;low latency;performance net6.0;net7.0;netstandard2.1