[ create a new paste ] login | about

Link: http://codepad.org/tuQedXI7    [ raw code | fork ]

C++, pasted on Oct 25:
#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();
}


Create a new paste based on this one


Comments: