NetSupportSocketReceiveAsync2 方法 |
接收固定长度的字节数组,允许指定超时时间,默认为60秒,当length大于0时,接收固定长度的数据内容,当length小于0时,buffer长度的缓存数据
Receiving a fixed-length byte array, allowing a specified timeout time. The default is 60 seconds. When length is greater than 0,
fixed-length data content is received. When length is less than 0, random data information of a length not greater than 2048 is received.
命名空间:
HslCommunication.Core
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:12.5.0.0 (12.5.0.0)
语法public static Task<OperateResult<int>> SocketReceiveAsync2(
Socket socket,
byte[] buffer,
int offset,
int length,
int timeOut,
Action<long, long> reportProgress,
Func<IAsyncResult, int> endMethod
)
Public Shared Function SocketReceiveAsync2 (
socket As Socket,
buffer As Byte(),
offset As Integer,
length As Integer,
timeOut As Integer,
reportProgress As Action(Of Long, Long),
endMethod As Func(Of IAsyncResult, Integer)
) As Task(Of OperateResult(Of Integer))
public:
static Task<OperateResult<int>^>^ SocketReceiveAsync2(
Socket^ socket,
array<unsigned char>^ buffer,
int offset,
int length,
int timeOut,
Action<long long, long long>^ reportProgress,
Func<IAsyncResult^, int>^ endMethod
)
static member SocketReceiveAsync2 :
socket : Socket *
buffer : byte[] *
offset : int *
length : int *
timeOut : int *
reportProgress : Action<int64, int64> *
endMethod : Func<IAsyncResult, int> -> Task<OperateResult<int>>
参数
- socket
- 类型:System.Net.SocketsSocket
网络通讯的套接字
Network communication socket - buffer
- 类型:SystemByte
等待接收的数据缓存信息 - offset
- 类型:SystemInt32
开始接收数据的偏移地址 - length
- 类型:SystemInt32
准备接收的数据长度,当length大于0时,接收固定长度的数据内容,当length小于0时,接收不大于1024长度的随机数据信息 - timeOut
- 类型:SystemInt32
单位:毫秒,超时时间,默认为60秒,如果设置小于0,则不检查超时时间 - reportProgress
- 类型:SystemActionInt64, Int64
当前接收数据的进度报告,有些协议支持传输非常大的数据内容,可以给与进度提示的功能 - endMethod
- 类型:SystemFuncIAsyncResult, Int32
[缺少 "M:HslCommunication.Core.NetSupport.SocketReceiveAsync2(System.Net.Sockets.Socket,System.Byte[],System.Int32,System.Int32,System.Int32,System.Action{System.Int64,System.Int64},System.Func{System.IAsyncResult,System.Int32})" 的 <param name="endMethod"/> 文档]
返回值
类型:
TaskOperateResultInt32包含了字节数据的结果类
参见