I'm using the Boost::asio to implement a client/server applicaion. The client code below is used to connect to the remote server .
try
{
boost::asio::io_service m_io_service;
boost::asio::ip::tcp::socket m_socket(m_io_service);
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::address::from_string("127.0.0.1"), 17);
m_socket.connect(endpoint);
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
}
At the client side, I want to check if the connection is live. The function "m_socket.is_open();
" doesn't work. When the server socket is closed, the "m_socket.is_open();
" still returns true at client side. Is there any way to check the connection?