简体   繁体   中英

Send UDP packet over specific period of time

I have a UDP client that send a number of packets to a server, I need to set a period of time between every packet, in other words I want to control the sending time of each packet.

How can I dot it? Help!

You cannot ask the socket to send the data at a certain point in time. All control you have about the sending time is by not calling send/sendto() until you want the sending to happen - even then, the TCP/IP stack is free to delay the actual packet sending, so you can only hope for the best. Basically, you get the current time from the OS, put the packet into the socket to be sent, sleep until the next packet is due, put the next packet into the socket, and so on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM