TCP/IP test preparation: a simple timer-boost implementation

Source: Internet
Author: User
The tcpip experiment needs to view the results at the specified time. for the convenience of the experiment, a timer is made. The usage is as follows: enter timer in the command line: after the time is reached, there will be 3 beeps and Timeisup will be displayed! The program is as follows: timer. cpp: g1_1_timer.cpp-otimer.exe-lboost_system-mgw48-1_56-lws2_3

The TCP/IP experiment needs to view the results at the specified time. for the convenience of the experiment, a timer is made. The usage is as follows:

Enter timer minutes in the command line.

When the Time is reached, there will be 3 beeps and the Time is up!

The procedure is as follows:

Timer. cpp:

// g++ timer.cpp -o timer.exe -lboost_system-mgw48-1_56 -lws2_32 -static#include 
 
  #include 
  
   #include 
   
    int main(int argc, char* argv[]){if (argc < 2){std::cout << "Usage: timer.exe minutes." << std::endl;return 1;}double minutes = boost::lexical_cast
    
     (argv[1]);int sec = (int)(minutes * 60);boost::asio::io_service io;boost::asio::deadline_timer timer(io, boost::posix_time::seconds(sec));timer.wait();char beep = 7;for (int i = 0; i < 3; ++i)std::cout << beep;std::cout << "Time is up!!!\n";return 0;}
    
   
  
 



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.