Skip to content

fix: Wrong resulting data length that sending after extra BasePacketLayer modification - #1064

Open
am1goo wants to merge 1 commit into
FirstGearGames:mainfrom
am1goo:fix/1063_correct_data_length_after_modification_by_extra_base_packet_layer
Open

fix: Wrong resulting data length that sending after extra BasePacketLayer modification#1064
am1goo wants to merge 1 commit into
FirstGearGames:mainfrom
am1goo:fix/1063_correct_data_length_after_modification_by_extra_base_packet_layer

Conversation

@am1goo

@am1goo am1goo commented Aug 11, 2026

Copy link
Copy Markdown

Description:
If any extra BasePacketLayer is in use and it change the resulting size of packet (in bytes) like "packet padding" technique, the final value of data length still equals packet.Size before any modifications.
Here the existing code of SendBroadcast method:

broadcastSuccess = _udpSocketv4.SendTo(packet.RawData, 0, packet.Size, SocketFlags.None, new IPEndPoint(IPAddress.Broadcast, port)) > 0;

if (_udpSocketv6 != null)
{
    multicastSuccess = _udpSocketv6.SendTo(packet.RawData, 0, packet.Size, SocketFlags.None, new IPEndPoint(MulticastAddressV6, port)) > 0;
}

Expected behavior:
The resulting size of data to send must equals the calculated data length from extra BasePacketLayer.
Here what it should be:

extraPacketLayer.ProcessOutBoundPacket(ref emptyEp, ref packet.RawData, ref checksumComputeStart, ref packetSize);

broadcastSuccess = _udpSocketv4.SendTo(packet.RawData, 0, packetSize, SocketFlags.None, new IPEndPoint(IPAddress.Broadcast, port)) > 0;

if (_udpSocketv6 != null)
{
    multicastSuccess = _udpSocketv6.SendTo(packet.RawData, 0, packetSize, SocketFlags.None, new IPEndPoint(MulticastAddressV6, port)) > 0;
}

More info at: #1063

@am1goo am1goo changed the title Issue 1063: fixed bug about wrong resulting data length that sending after extra BasePacketLayer modification fix: issue 1063: fixed bug about wrong resulting data length that sending after extra BasePacketLayer modification Aug 11, 2026
@am1goo am1goo changed the title fix: issue 1063: fixed bug about wrong resulting data length that sending after extra BasePacketLayer modification fix: Wrong resulting data length that sending after extra BasePacketLayer modification Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant