关于 C++ 的问题定时器
我目前正在开发一个项目,该项目将像亚马逊或 Ebay 等规模非常小的在线销售网站一样。我想知道是否有人可以为我指明如何使用 C++ 定时器的正确方向。目前正在学习套接字编程,并试图在有人出售其产品时将计时器纳入拍卖时间。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的意思是像timer_create?
你如何处理你的套接字?线程还是
选择
?如果是后者(或类似 select 的东西),timer_create 将是一个自然的选择。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.C++没有内置定时器。您愿意使用哪些库确实会影响您的答案。
操作系统将具有内置计时器,其他库(如 Boost)(在另一个答案中提到)或工具包(如 Qt)或运行时系统(如 .NET)也将具有可用的计时器。
我建议您在继续之前更详细地描述您的环境。
您使用什么套接字?如果它是一个相对知名的 API,它也可能有一个计时器实现。旁注:您还需要研究用于套接字的线程。
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.
boost::asio 计时器,或 boost 计时器库 (http: //www.boost.org/doc/libs/1_40_0/libs/timer/index.html)。或者只使用本机操作系统计时器功能,例如,在 Windows 中,它是 SetTimer 和 KillTime。
boost::asio timers, or the boost timer library (http://www.boost.org/doc/libs/1_40_0/libs/timer/index.html). Or just use the native OS timer functionalities, e.g., in Windows it'll be SetTimer and KillTime.