Linux udp socket how to package, immediately send a package?
Time:09-23
Masters, ask questions, the younger brother beginners Linux socket network programming, in the realization of an algorithm, algorithm requirement is sending a udp message (1472 bytes), strictly control each udp send time, an example is the t1 time send udp1, send udp2 t2 time, t3 send udp3 time,,,, almost will send hundreds of packages, t1, t2, t3 is the time interval between I (algorithm) of strict control, not to take into consideration the disturbance of the system call on time (in the underlying contract, of course, the fastest most accurate),
I want to achieve the effect of application is a package to send out, then send the second package,,, third, fourth, but Internet learned that the system will be independent package, which means that although I call write function to send the first package, but packages in the kernel (or any other places or interfaces that are not immediately go, will wait for a period of time, and then sent out together, (because don't want to waste of resources, a package is sent a scheduling a too expensive),
Like every three seconds for example assumes that the system is to send a package, I 1 s clock write functions at the time of the first package, 2 s clock is sort of the write function to send the second package, 3 s clock call write function to send a third udp packets, but actually in the system, the first tone after the write 1 package waiting for no. 2 and 3 packages in the together and then throw (because 3 s hair once, etc.), the result is not what I want contract time sequence, 1 bag and no. 2, 3 packets to send time is the same, in fact, I then statistical time stamp is the number one package arrived for the longest time, 2 second 3 package, and every time is the result, also confirm the package waiting for 1 # 2, 3 packages
is there any way I can make the system package, send immediately? online checked 1. Call the fflush function, it can immediately send the package, fflush (FILE * stream) function how to cooperate to use with the udp socket interface? Seems to be to write a file I/O to use fflush function, this method is feasible? Fflush function how to use with the socket? 2. The Internet also went close GSO function, which is more appropriate? Thank you all!
CodePudding user response:
Udp does not naturally agreement is based on the package?