I'm late to this thread, but the heading says "UDP."
UDP is not like TCP. The sendto() call either takes the full packet, or nothing at all. A fractional packet doesn't make sense.
Also, write() in general doesn't make sense for UDP. So maybe you switched to TCP somewhere in this thread?
Finally, just spin-looping when a non-blocking socket returns "not ready" is not helpful; the CPU is much faster than the network. The thing you need to do is either put your data in a queue for later delivery, or immediately decide to drop it. (If you jammed the send buffer full already, you're sending faster than the network can deliver, anyway.)