Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Netcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,14 @@ public void SendPacket(in Address to, ReadOnlySpan<byte> packetData)
/// <summary>Non-blocking receive. Returns 0 when no packet is available.</summary>
public int ReceivePacket(ref Address from, Span<byte> packetData)
{
// ReceiveFrom requires Size >= the family maximum before every call, and
// .NET 8 overwrites Size BEFORE checking the recvfrom result — so an empty
// poll (EWOULDBLOCK, the common case on a non-blocking socket) zeroes it
// and the next call throws ArgumentOutOfRangeException ("SocketAddress is
// too small"). .NET 9 moved that assignment after the error check. Re-arm
// the size each call; it is a field store, nothing allocates.
_receiveAddress.Size = SocketAddress.GetMaximumAddressSize(_socket.AddressFamily);

int result;
try
{
Expand Down