Skip to content

Class UdpStateObject

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

对异步接收时的对象状态的封装,将socket与接收到的数据封装在一起

csharp
public class UdpStateObject : StateObject

Inheritance

objectStateObjectUdpStateObject

Inherited Members

StateObject.EmptyIpv4Port, StateObject.HeadSize, StateObject.KeepAliveObj, StateObject.CreateSocket(bool, NetBufferSize), StateObject.SocketIsDispose(Socket), StateObject.HashCodeByte(in Memory<byte>), StateObject.QueueUserWorkItem<T>(ReceiveEvent<T>, ReceiveBytes<T>), StateObject.ReceivedAsync<T>(ReceiveEvent<T>, ReceiveBytes<T>), StateObject.GetIpPort(HttpListenerContext), StateObject.GetIpPort(Socket), StateObject.GetIpPort(EndPoint), StateObject.IsIpPort(string, out Ipv4Port), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

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)

Remarks

代码由逆血提供支持

Constructors

UdpStateObject(IUdpCore, int, bool, ReceiveEvent<IUdpCore>)

有参构造

csharp
public UdpStateObject(IUdpCore udp, int DataLength, bool OnlyData, ReceiveEvent<IUdpCore> Received)

Parameters

udp IUdpCore

udp信息

DataLength int

包的大小

OnlyData bool

是否保证有效

Received ReceiveEvent<IUdpCore>

完成时事件

Properties

DataLength

可用最大空间

csharp
public int DataLength { get; }

Property Value

int

IpPort

当前对象唯一的IP:端口

csharp
public UserKey IpPort { get; }

Property Value

UserKey

OnlyData

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

csharp
public bool OnlyData { get; }

Property Value

bool

Udp

当前有个通信信息

csharp
public IUdpCore Udp { get; }

Property Value

IUdpCore

Methods

Close()

回收对象所以资源

csharp
public void Close()

IsConnected(Socket)

根据Socket获取当前连接是否已经断开

csharp
public static bool IsConnected(Socket Client)

Parameters

Client Socket

Returns

bool

IsOnLine(int)

当前连接是否在线

csharp
public bool IsOnLine(int receiveTimeout)

Parameters

receiveTimeout int

参数为超时最大值

Returns

bool

基于Apache-2.0协议开源