Skip to content

Struct SendBytes<ISocket>

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

Socket 通讯资源 对象(必须回收,丢失风险大)

csharp
public readonly struct SendBytes<ISocket> : IBytesCore, IDisposable, IAsyncDisposable

Type Parameters

ISocket

Implements

IBytesCore, IDisposable, IAsyncDisposable

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), 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)

Constructors

SendBytes(ISocket, int, bool)

资源对象

csharp
public SendBytes(ISocket client, int length, bool onlydata)

Parameters

client ISocket

连接对象

length int

包含长度

onlydata bool

数据包完整

SendBytes(ISocket, IMemoryOwner<byte>, int, bool)

资源对象

csharp
public SendBytes(ISocket client, IMemoryOwner<byte> dataOwner, int length, bool onlydata)

Parameters

client ISocket

连接对象

dataOwner IMemoryOwner<byte>

可回收数据对象

length int

包含长度

onlydata bool

数据包完整

SendBytes(ISocket, in BytesCore, bool)

资源对象

csharp
public SendBytes(ISocket client, in BytesCore bytesCore, bool onlydata)

Parameters

client ISocket

连接对象

bytesCore BytesCore

可回收数据对象

onlydata bool

数据包完整

Properties

Array

获取连续内存

csharp
public ArraySegment<byte> Array { get; }

Property Value

ArraySegment<byte>

Client

连接对象

csharp
public ISocket Client { get; }

Property Value

ISocket

IsDispose

获取是否被回收

csharp
public bool IsDispose { get; }

Property Value

bool

Length

流长度

csharp
public int Length { get; }

Property Value

int

Memory

返回数据

csharp
public Memory<byte> Memory { get; }

Property Value

Memory<byte>

OnlyData

表示是否需要验证数据包

csharp
public bool OnlyData { get; }

Property Value

bool

Span

返回数据

csharp
public Span<byte> Span { get; }

Property Value

Span<byte>

Methods

Dispose()

使用完后及时回收

csharp
public void Dispose()

GetIMemoryOwner()

获取内存器核心

csharp
public IMemoryOwner<byte> GetIMemoryOwner()

Returns

IMemoryOwner<byte>

GetMemory()

获取有效的发送数据包

csharp
public Memory<byte> GetMemory()

Returns

Memory<byte>

GetMemory(uint, byte)

获取有效的发送数据包(UDP协议版)

csharp
public Memory<byte> GetMemory(uint orderCount, byte code = 0)

Parameters

orderCount uint

序列ID

code byte

协议代号

Returns

Memory<byte>

SetMemory(in Memory<byte>, int)

写入有效的发送数据包

csharp
public void SetMemory(in Memory<byte> memory, int start = 0)

Parameters

memory Memory<byte>

start int

SetMemory(in Span<byte>, int)

写入有效的发送数据包

csharp
public void SetMemory(in Span<byte> span, int start = 0)

Parameters

span Span<byte>

start int

SetMemory(in ArraySegment<byte>, int)

写入有效的发送数据包

csharp
public void SetMemory(in ArraySegment<byte> bytes, int start = 0)

Parameters

bytes ArraySegment<byte>

start int

Slice(int, int)

用于进行输出缩减包大小

csharp
public SendBytes<ISocket> Slice(int start, int length)

Parameters

start int

只能是0

length int

小于总大小的数

Returns

SendBytes<ISocket>

Exceptions

Exception

ToString()

文本信息

csharp
public override string ToString()

Returns

string

TransferByte()

移交内存器

csharp
public BytesCore TransferByte()

Returns

BytesCore

基于Apache-2.0协议开源