Solved: How to handle exception with Boost Asio and C C++ to avoid . . . boost::asio::write(s, boost::asio::buffer(heading_data, heading_length)); Select all Open in new window and everything works well if the server is connected, but if i try to connect the client when the server is closed, i get this error: