How would I implement flush() for UDP?

I’d like to know when the UDP TX buffer is empty so I can start timing for a timeout while waiting for an ACK. (I’m trying to write a TFTP library to get data off a P0/P1 and this is the last bit).

However, the UDP flush() method in the docs says the method doesn’t actually do anything yet and while poking around in the firmware both the UDP and TCP flush() methods are actually empty (I thought maybe I could check out how it was done in TCP).

Or… maybe I don’t need flush? Is endPacket() already a blocking call until it empties the TX buffer?

@KyleG can see if the firmware team has an answer for this?

What i’m really trying to get to is figuring out an estimate of the round trip time, so it would be great if there was some way to know when a packet was finished sending.

Based on a different post by @kennethlimcp I switched to sendPacket/receivePacket (which I like better) but still have the same general question, since I’m not entirely sure if these block.

@rickkas7 can you take a look at this.

I’m pretty sure it’s not necessary to flush UDP.

I recommend UDP sendPacket since it’s a more efficient way to build the packet, and also it returns an error code if the send fails. It passes the data all the way into the TCP/IP stack without copying and returns an error if it fails, so I believe wiced_udp_send sends immediately so there’s no need to flush.


It sounds like for calculating round trip time, if I start the clock right after sendPacket and stop it when I receive an Ack… that should be close enough.