Created
June 18, 2013 14:42
-
-
Save rahul8590/5805934 to your computer and use it in GitHub Desktop.
Just goofing around Boost ASIO library . The following is the first attempt to mess with it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You also need to link pthread and boost_system in order to run it. The following will be the command , if you are too lazy to | |
// type | |
// $ g++ sample_asio.cpp -o asio -lpthread -lboost_system | |
// | |
#include <boost/asio.hpp> | |
#include <iostream> | |
using namespace std; | |
void handler(const boost::system::error_code &ec) | |
{ | |
cout << "printing after 5 sec"; | |
} | |
int main() | |
{ | |
boost::asio::io_service io_service; | |
boost::asio::deadline_timer timer(io_service, boost::posix_time::seconds(5)); | |
timer.async_wait(handler); | |
io_service.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment