Hi, I was wondering how I can find out with ASIO whether a connection is broken. I have a client connected to the server that continuously streams data. I have to know at the client-side when the server has hung up. I tried to use an async_write and after 5 erroneous tries the running thread for the connection is terminated. Like this: void connection::run_thread() { while (!stopped()) { event_ptr e = fetch_event(); if (!stopped()) { int write_tries = 0; boost::asio::async_write(_socket, boost::asio::buffer(*e, e->length()), boost::bind(&connection::handle_write, this, boost::asio::placeholders::error, e, write_tries)); } } } void connection::handle_write(const boost::system::error_code &err, const event_ptr event, int write_tries) { if (write_tries == max_write_tries) stopped(true); // thread will break out of its main-loop after being notified if (stopped()) return; // no meaning to continue if (err) { // incremenent write_tries and retry async_write boost::asio::async_write(_socket, boost::asio::buffer(*event, event->length()), boost::bind(&connection::handle_write, this, boost::asio::placeholders::error, event, ++write_tries)); } } I think I am misunderstanding something. I thought that after a async_write the registered handler will be invoked. But the handler is NEVER invoked somehow, although data is send from the client to the server. I have the following questions: - Why is the handler never invoked? When is it supposed to be invoked? - What is the best way to find out a connection has been reset by the server? And client? Thanks alot, Andrej ___________________________________________________________ Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.htm...