Jump to content
  • Advertisement
Sign in to follow this  
Elric

How can I manage time in C++?

This topic is 3781 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I need to manage time in C++. For example I need to create and send 10 packets (to network) in a second. For this I will need a timer that is being updated by microseconds maybe. How can I accomplish this? Thanks...

Share this post


Link to post
Share on other sites
Advertisement
The c standard library includes the time() function made available in the time.h/ctime header. This timer has 1 second resolution and pretty poor accuracy for real-time applications.

The availability of higher resolution timing depends on your operating system. *nix systems provide the function gettimeofday() which has microsecond resolution. On windows you'll want to look at the multimedia timer (I'm sure windows has more timers available, the mm timer is just one of them).

For extra portability you should examine the boost::date_time library and see what timing functions are available.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!