iml6yu.FKSocket
0.0.1-bate2202403
This is a prerelease version of iml6yu.FKSocket.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package iml6yu.FKSocket --version 0.0.1-bate2202403
NuGet\Install-Package iml6yu.FKSocket -Version 0.0.1-bate2202403
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="iml6yu.FKSocket" Version="0.0.1-bate2202403" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add iml6yu.FKSocket --version 0.0.1-bate2202403
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: iml6yu.FKSocket, 0.0.1-bate2202403"
#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 iml6yu.FKSocket as a Cake Addin #addin nuget:?package=iml6yu.FKSocket&version=0.0.1-bate2202403&prerelease // Install iml6yu.FKSocket as a Cake Tool #tool nuget:?package=iml6yu.FKSocket&version=0.0.1-bate2202403&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
@[TOC]
FKSocket
一个超级轻量的socket类库,一切才刚刚开始,还有很多工作要做。
Clients
客户端,包含客户端的连接,心跳等方法
FKSocketManage
客户端管理对象 用法
//创建一个客户端对象
var client = FKSocketManager.CreateClient(new SocketOption()
{
Host = "127.0.0.1",
Port = 30000
});
FKSocketClient
客户端对象,创建后需要关注几个事件
//连接状态
client.ConnectStateChanged += (flag, msg) =>
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"连接状态:{flag},描述信息:{msg}");
Console.ForegroundColor = ConsoleColor.White;
};
//收到数据
client.Received += (msg) =>
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"接收到信息:{msg}");
Console.ForegroundColor = ConsoleColor.White;
};
连接客户端
client.Connect();
启用心跳管理
//默认10s检测时间
client.OpenHeartCheck();
启用断线重连
client.Connect().OpenHeartCheck()
//打开断线重连
.OpenAutoReConnection(3);
断线重连效果
简写
client.Connect().OpenHeartCheck();
完整demo代码
// See https://aka.ms/new-console-template for more information
using iml6yu.FKSocket;
Console.WriteLine("Hello, World!");
var client = FKSocketManager.CreateClient(new SocketOption()
{
Host = "127.0.0.1",
Port = 30000
});
//连接状态
client.ConnectStateChanged += (flag, msg) =>
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"连接状态:{flag},描述信息:{msg}");
Console.ForegroundColor = ConsoleColor.White;
};
//收到数据
client.Received += (msg) =>
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"接收到信息:{msg}");
Console.ForegroundColor = ConsoleColor.White;
};
client.Connect().OpenHeartCheck();
string input;
Console.WriteLine("请输入您需要发送的内容!");
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
while ((input = Console.ReadLine()) != "exit")
{
client.Send(input);
Console.WriteLine("请输入您需要发送的内容!");
}
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
client.Dispose();
Console.WriteLine("一切到此结束了!");
效果
连接
Product | Versions 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 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- No dependencies.
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.0.1-bate22060902 | 160 | 6/9/2022 | |
0.0.1-bate22060901 | 147 | 6/9/2022 | |
0.0.1-bate2202502 | 138 | 3/25/2022 | |
0.0.1-bate2202501 | 115 | 3/25/2022 | |
0.0.1-bate2202403 | 155 | 3/24/2022 | |
0.0.1-bate2202402 | 115 | 3/24/2022 |
第一个仅包含客户端的tcp通信类