Пример #1
0
 public static ArraySegment <byte> ReceiveArraySegment(this Socket socket, ArraySegment <byte> segment)
 {
     return(segment.Take(socket.Receive(segment)));
 }
Пример #2
0
 /// <summary>
 ///     Creates a new array segment by skipping a number of elements from the end of this array segment.
 /// </summary>
 /// <typeparam name="T">The type of elements contained in the array.</typeparam>
 /// <param name="segment">The array segment.</param>
 /// <param name="count">
 ///     The number of elements to skip. This must be in the range
 ///     <c>[0, <paramref name="segment" />.Count]</c>.
 /// </param>
 /// <returns>The new array segment.</returns>
 public static ArraySegment <T> SkipLast <T>(this ArraySegment <T> segment, int count)
 {
     return(segment.Take(segment.Count - count));
 }
Пример #3
0
 public static async Task <ArraySegment <byte> > ReceiveArraySegmentAsync(this Socket socket, ArraySegment <byte> segment)
 {
     return(segment.Take(await socket.ReceiveAsync(segment)));
 }