gh-113812: Allow DatagramTransport.sendto to send empty data by ordinary-jamie · Pull Request #115199 · python/cpython (original) (raw)

@gvanrossum -- This might cause an issue with the flow control of the transport. Since the buffer size is calculated with only the payload (and not the entire datagram).

The write buffer could in theory be flooded with zero-length datagrams, and the high watermark will never be crossed.

Oh, that's a very good point. I think we could add a constant value to the "buffer size" for each packet added -- the only use for the buffer size is to interact with flow control. In fact, after skimming the UDP Wikipedia page, I think we can add 8 for each packet, since that's the protocol's header size.