I connected a non-existent address using tcp::socket::connect method and it returned WSAETIMEDOUT(10060) as expected. But why invoking tcp::socket::is_open() returned 1(true) ? I think it should return 0(false), because of establishing connection failed.
int main(int argc, char* argv[]) {
boost::asio::io_context context;
tcp::socket socket(context);
/*non-existent address 111.111.111.111:8080*/
tcp::endpoint endpoint(address::from_string("111.111.111.111"), 8080);
error_code result_error;
socket.connect(endpoint, result_error);
/* error code: WSAETIMEDOUT [10060]
* description: established connection failed because connected host has failed to respond
*/
std::cout << "error code: " << result_error.value()<< result_error.message() << std::endl;
/*returned 1*/
std::cout << "is_open returned: "<< socket.is_open() << std::endl;
}
I expect the output of is_open to be 0, but the actual output is 1.