views:

139

answers:

3

I am currently working on a project that will act like a Online selling website such as Amazon, or Ebay in a very small scale. I was wondering if anyone could point me in the right direction on how to use Timers for C++. Learning Socket Programming at the moment, and was trying to incorporate the timer for the auction time when someone is selling their product.

Thanks

+3  A: 

You mean like timer_create?

How are you handling your sockets? Threads or select? If the latter (or something like select), timer_create will be a natural fit.

John Zwinck
Yes I am using Select, Thank so much ^^
ej
+1  A: 

boost::asio timers, or the boost timer library (http://www.boost.org/doc/libs/1%5F40%5F0/libs/timer/index.html). Or just use the native OS timer functionalities, e.g., in Windows it'll be SetTimer and KillTime.

navigator
+3  A: 

C++ does not have built-in timers. What libraries you are willing to use really makes the difference in your answer.

Operating systems will have built-in timers, other libraries like Boost (mentioned in another answer), or toolkits like Qt or runtime systems like .NET will also have timers available.

I recommend you describe your environment in more detail before moving on.

What are you using for the Sockets? If it's a relatively well-known API, it will likely have a timer implementation as well. side note: You'll also want to look into threads to use for your sockets.

San Jacinto
C++ may not have timers, but POSIX does (see my answer).
John Zwinck
@John Zwinck Yup, that was my point. He didn't describe what he was using to code. You guessed correctly. Navigator did not.
San Jacinto