I'm writing two programs(on visual studio), one sending and one receiving UDP packets(1,000 bytes). Currently, my sender is sending a udp packet, sleep for 1 ms, before sending another packet. To increase the rate, i made the sender sleep for 1 ms only after sending about 20packets. Problem is if i increase the number of packets before each sleep, the receiver tend to miss packets. So i thought maybe if i increase the socket buffer size it will be better?
I know TCP is a safer choice, but let's assume i can only use UDP, and i need to ensure i can send packets over at a high rate with no missing packets, what should i do? And how do i check what is my socket buffer size? Currently my program only used 'sethost' and 'bind', followed by 'sendto' to send udp packets.
setsockopt()
/SO_RCVBUF
, then have the receiving side dedicate a thread to reading incoming network data into the application's queue as quickly as possible, so other data processing doesn't block/slow the receipt leading to packet loss. Increase the scheduler priority if necessary. Then pray. This approach is only really ok if you can afford to lose data. – Tony Delroy