lsalzman / enet

ENet reliable UDP networking library
MIT License
2.77k stars 673 forks source link

Clarify the actual purpose of `ENET_PACKET_FLAG_SENT` #259

Open cher-nov opened 5 months ago

cher-nov commented 5 months ago

It is currently not clear from the documentation that the sole purpose of ENET_PACKET_FLAG_SENT is to check for it in the designated packet->freeCallback function when releasing the packet. This is according directly to the next code:

https://github.com/lsalzman/enet/blob/a356ac0aa90c212903f19c52d7215158ca54cfdb/protocol.c#L175-L185

https://github.com/lsalzman/enet/blob/a356ac0aa90c212903f19c52d7215158ca54cfdb/protocol.c#L267-L280

https://github.com/lsalzman/enet/blob/a356ac0aa90c212903f19c52d7215158ca54cfdb/packet.c#L53-L68

Also, the name of the constant itself is somewhat ambiguous, since the documentation does not indicate whether it is set only upon a complete transfer of the packet (i.e. acknowledged delivery) or after any partial / failed / etc attempts.

The ability for the sender to check this flag on the packet is very useful, for example, in the case of transferring large files so as not to store them entirely in memory and not send explicit delivery confirmations in addition to the already existing library ones (and therefore redundant).