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;}