/// <summary> /// 分割数据并顺序添加到待发送数据集合 /// </summary> /// <param name="byteRange">数据</param> /// <returns>返回拆分数量</returns> private int SplitByteRangeToQueue(ByteRange byteRange) { var byteRanges = byteRange.SplitBySize(EventArgBufferSetter.ARG_BUFFER_SIZE); lock (this.queueSync) { var count = 0; foreach (var range in byteRanges) { this.byteRangeQueue.Enqueue(range); count++; } return(count); } }
/// <summary> /// 异步发送数据 /// </summary> /// <param name="byteRange">数据范围</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="SocketException"></exception> public void Send(ByteRange byteRange) { if (byteRange == null) { throw new ArgumentNullException(); } if (this.IsConnected == false) { throw new SocketException((int)SocketError.NotConnected); } var byteRanges = byteRange.SplitBySize(EventArgBufferSetter.ARG_BUFFER_SIZE); foreach (var range in byteRanges) { this.SendByteRange(range); } }
/// <summary> /// 分割数据并顺序添加到待发送数据集合 /// </summary> /// <param name="byteRange">数据</param> /// <returns>返回拆分数量</returns> private int SplitByteRangeToQueue(ByteRange byteRange) { var byteRanges = byteRange.SplitBySize(EventArgBufferSetter.ARG_BUFFER_SIZE); lock (this.queueSync) { var count = 0; foreach (var range in byteRanges) { this.byteRangeQueue.Enqueue(range); count++; } return count; } }