public static ArraySegment <byte> ReceiveArraySegment(this Socket socket, ArraySegment <byte> segment) { return(segment.Take(socket.Receive(segment))); }
/// <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)); }
public static async Task <ArraySegment <byte> > ReceiveArraySegmentAsync(this Socket socket, ArraySegment <byte> segment) { return(segment.Take(await socket.ReceiveAsync(segment))); }