Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 89abe20

Browse files
committed
Simplify ReceiveMessageFromAsync signature
Do the slicing at the call sites to avoid passing in a separate offset and count.
1 parent 28fea46 commit 89abe20

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

src/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncContext.Unix.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,12 +1282,10 @@ public SocketError ReceiveMessageFrom(
12821282
return operation.ErrorCode;
12831283
}
12841284

1285-
public SocketError ReceiveMessageFromAsync(Memory<byte> buffer, IList<ArraySegment<byte>> buffers, int offset, int count, SocketFlags flags, byte[] socketAddress, ref int socketAddressLen, bool isIPv4, bool isIPv6, out int bytesReceived, out SocketFlags receivedFlags, out IPPacketInformation ipPacketInformation, Action<int, byte[], int, SocketFlags, IPPacketInformation, SocketError> callback)
1285+
public SocketError ReceiveMessageFromAsync(Memory<byte> buffer, IList<ArraySegment<byte>> buffers, SocketFlags flags, byte[] socketAddress, ref int socketAddressLen, bool isIPv4, bool isIPv6, out int bytesReceived, out SocketFlags receivedFlags, out IPPacketInformation ipPacketInformation, Action<int, byte[], int, SocketFlags, IPPacketInformation, SocketError> callback)
12861286
{
12871287
SetNonBlocking();
12881288

1289-
buffer = buffer.Slice(offset, count);
1290-
12911289
SocketError errorCode;
12921290
int observedSequenceNumber;
12931291
if (_receiveQueue.IsReady(this, out observedSequenceNumber) &&

src/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ internal unsafe SocketError DoOperationReceiveMessageFrom(Socket socket, SafeClo
211211
int bytesReceived;
212212
SocketFlags receivedFlags;
213213
IPPacketInformation ipPacketInformation;
214-
SocketError socketError = handle.AsyncContext.ReceiveMessageFromAsync(_buffer, _bufferListInternal, _offset, _count, _socketFlags, _socketAddress.Buffer, ref socketAddressSize, isIPv4, isIPv6, out bytesReceived, out receivedFlags, out ipPacketInformation, ReceiveMessageFromCompletionCallback);
214+
SocketError socketError = handle.AsyncContext.ReceiveMessageFromAsync(_buffer.Slice(_offset, _count), _bufferListInternal, _socketFlags, _socketAddress.Buffer, ref socketAddressSize, isIPv4, isIPv6, out bytesReceived, out receivedFlags, out ipPacketInformation, ReceiveMessageFromCompletionCallback);
215215
if (socketError != SocketError.IOPending)
216216
{
217217
CompleteReceiveMessageFromOperation(bytesReceived, _socketAddress.Buffer, socketAddressSize, receivedFlags, ipPacketInformation, socketError);

src/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ public static SocketError ReceiveMessageFromAsync(Socket socket, SafeCloseSocket
16761676
int bytesReceived;
16771677
SocketFlags receivedFlags;
16781678
IPPacketInformation ipPacketInformation;
1679-
SocketError socketError = handle.AsyncContext.ReceiveMessageFromAsync(buffer, null, offset, count, socketFlags, socketAddress.Buffer, ref socketAddressSize, isIPv4, isIPv6, out bytesReceived, out receivedFlags, out ipPacketInformation, asyncResult.CompletionCallback);
1679+
SocketError socketError = handle.AsyncContext.ReceiveMessageFromAsync(new Memory<byte>(buffer, offset, count), null, socketFlags, socketAddress.Buffer, ref socketAddressSize, isIPv4, isIPv6, out bytesReceived, out receivedFlags, out ipPacketInformation, asyncResult.CompletionCallback);
16801680
if (socketError == SocketError.Success)
16811681
{
16821682
asyncResult.CompletionCallback(bytesReceived, socketAddress.Buffer, socketAddressSize, receivedFlags, ipPacketInformation, SocketError.Success);

0 commit comments

Comments
 (0)