NetworkBaseReceiveAsync 方法 (Socket, Int32, Int32, ActionInt64, Int64) |
接收固定长度的字节数组,允许指定超时时间,默认为60秒,当length大于0时,接收固定长度的数据内容,当length小于0时,接收不大于2048长度的随机数据信息
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.Net
程序集:
HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法 protected Task<OperateResult<byte[]>> ReceiveAsync(
Socket socket,
int length,
int timeOut = 60000,
Action<long, long> reportProgress = null
)
Protected Function ReceiveAsync (
socket As Socket,
length As Integer,
Optional timeOut As Integer = 60000,
Optional reportProgress As Action(Of Long, Long) = Nothing
) As Task(Of OperateResult(Of Byte()))
protected:
Task<OperateResult<array<unsigned char>^>^>^ ReceiveAsync(
Socket^ socket,
int length,
int timeOut = 60000,
Action<long long, long long>^ reportProgress = nullptr
)
member ReceiveAsync :
socket : Socket *
length : int *
?timeOut : int *
?reportProgress : Action<int64, int64>
(* Defaults:
let _timeOut = defaultArg timeOut 60000
let _reportProgress = defaultArg reportProgress null
*)
-> Task<OperateResult<byte[]>>
参数
- socket
- 类型:System.Net.SocketsSocket
网络通讯的套接字
Network communication socket - length
- 类型:SystemInt32
准备接收的数据长度,当length大于0时,接收固定长度的数据内容,当length小于0时,接收不大于1024长度的随机数据信息 - timeOut (Optional)
- 类型:SystemInt32
单位:毫秒,超时时间,默认为60秒,如果设置小于0,则不检查超时时间 - reportProgress (Optional)
- 类型:SystemActionInt64, Int64
当前接收数据的进度报告,有些协议支持传输非常大的数据内容,可以给与进度提示的功能
返回值
类型:
TaskOperateResultByte包含了字节数据的结果类
参见