codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> #include <stdexcept> #include <boost/asio.hpp> #include <boost/asio/spawn.hpp> using namespace std; using namespace boost::asio; using namespace boost::asio::ip; io_service iosrv; void test(yield_context yield) { tcp::socket m_socket(iosrv); try { cout << "1" << endl; tcp::resolver resolver(iosrv); cout << "2" << endl; auto endpoints = resolver.async_resolve(tcp::resolver::query("nonexistingdomain.com", "1111"), yield); cout << "3" << endl; async_connect(m_socket, endpoints, yield); cout << "4" << endl; } catch (const exception& e) { cout << "Caught " << e.what() << endl; } catch (...) { cout << "Caught whatever" << endl; } } int main(int argc, char* argv[]) { strand s(iosrv); spawn(s, test); iosrv.run(); }
Private
[
?
]
Run code
Submit