blocking read after async connect
I have a class that performs a timed connect (i.e. using an async connect that returns an error if connection failed/timed-out). However every asio::read/write performed on the socket after a successful async_connect fails. Any ideas? Is it impossible to perform read/write on such a socket? do I have to stop() the io service to put it back into synchronous mode?
I have a class that performs a timed connect (i.e. using an async connect that returns an error if connection failed/timed-out). However every asio::read/write performed on the socket after a successful async_connect fails.
Any ideas? Is it impossible to perform read/write on such a socket? do I have to stop() the io service to put it back into synchronous mode?
AFAIK, there's no problem to mix sync./async. operations this way. What do you mean by saying "fails"? What error/exception do you encounter?
I have a class that performs a timed connect (i.e. using an async connect that returns an error if connection failed/timed-out). However every asio::read/write performed on the socket after a successful async_connect fails.
Any ideas? Is it impossible to perform read/write on such a socket? do I have to stop() the io service to put it back into synchronous mode?
AFAIK, there's no problem to mix sync./async. operations this way. What do you mean by saying "fails"? What error/exception do you encounter?
I find that unless I call io_service::stop() , I can't perform a asio::read(). It's actually on a thread and I'm having difficulty seeing what the exception thrown exactly is ('thread called terminate')
I find that unless I call io_service::stop() , I can't perform a asio::read(). It's actually on a thread and I'm having difficulty seeing what the exception thrown exactly is ('thread called terminate')
Use your own thread function to see what happened to your io_service: void do_run(io_service *io) { try { io->run(); std::cout << "io_service::run ended" <<std::eol; } catch(std::exception &e) { std::cout << e.what() <<std::eol; } catch(...) { std::cout << "some other exception" <<std::eol; } } //... thread t(&do_run, &io_service);
participants (2)
-
David Kaplan
-
Igor R