Skip to content

Interface IUdpCore

Namespace: Tool.Sockets.UdpHelper
Assembly: Tool.Net.dll

Udp通信核心,管理相关连接信息

csharp
public interface IUdpCore : IAsyncDisposable

Implements

IAsyncDisposable

Extension Methods

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Properties

DataLength

可用最大空间

csharp
int DataLength { get; }

Property Value

int

EndPoint

连接的设备地址信息

csharp
UdpEndPoint EndPoint { get; }

Property Value

UdpEndPoint

Ipv4

获取IpV4地址信息

csharp
Ipv4Port Ipv4 { get; }

Property Value

Ipv4Port

LimitingSize

控制滑动窗口大小(限制流量)备注:计算得出1000个窗口比较满足大多数环境

csharp
public static int LimitingSize { get; set; }

Property Value

int

OnlyData

是否保证数据唯一性,开启后将采用框架验证保证其每次的数据唯一性,(如果不满足数据条件将直接与其断开连接)

csharp
bool OnlyData { get; }

Property Value

bool

Socket

连接的对象(请勿脱离框架使用,避免出现各种未知异常)

csharp
Socket Socket { get; }

Property Value

Socket

SpinWaitTimeout

分配id最大等待时间

csharp
public static int SpinWaitTimeout { get; set; }

Property Value

int

Methods

CloseAsync()

尝试异步关闭连接

csharp
Task CloseAsync()

Returns

Task

GetUdpCore(INetworkCore, UdpEndPoint, Socket, int, bool, int, bool, bool, Func<UserKey, byte, ValueTask>, ReceiveEvent<IUdpCore>)

创建可用的公共UDP核心

csharp
public static IUdpCore GetUdpCore(INetworkCore networkCore, UdpEndPoint endPoint, Socket socket, int dataLength, bool onlyData, int replyDelay, bool isserver, bool isp2p, Func<UserKey, byte, ValueTask> complete, ReceiveEvent<IUdpCore> received)

Parameters

networkCore INetworkCore

endPoint UdpEndPoint

socket Socket

dataLength int

onlyData bool

replyDelay int

isserver bool

isp2p bool

complete Func<UserKey, byte, ValueTask>

received ReceiveEvent<IUdpCore>

Returns

IUdpCore

SendAsync(Memory<byte>)

直接发送数据(警告非对内核完全了解的开发者,请谨慎,会出现各种未知异常!)

csharp
Task SendAsync(Memory<byte> memory)

Parameters

memory Memory<byte>

发送的数据

Returns

Task

基于Apache-2.0协议开源