[Boost-bugs] [Boost C++ Libraries] #10744: wrong error code when doing async_connect and the connection is refused

Subject: [Boost-bugs] [Boost C++ Libraries] #10744: wrong error code when doing async_connect and the connection is refused
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-11-04 08:56:02


#10744: wrong error code when doing async_connect and the connection is refused
-----------------------------------------------+---------------------------
 Reporter: Martin Bonetti <martin.bonetti@…> | Owner:
     Type: Bugs | chris_kohlhoff
Milestone: To Be Determined | Status: new
  Version: Boost 1.56.0 | Component: asio
 Keywords: errror_code, async_connect | Severity: Regression
-----------------------------------------------+---------------------------
 When executing the following example the error_code provided is not
 correctly recognized as connection_refused.

 This is because the error_code supplied is provided by '''GetLastError'''
 and the error_code expected is provided by '''WSAGetLastError'''.

 {{{
 #!div style="font-size: 80%"
   {{{#!cpp
 #include <iostream>
 #include "boost/asio.hpp"

 using namespace boost::asio;

 int main(int argc, const char* argv[]) {
    io_service io_service;
    ip::tcp::socket::endpoint_type
 endpoint(ip::address_v4::from_string("127.0.0.1"), 9999);
    ip::tcp::socket tcp_socket(io_service);

    tcp_socket.async_connect(endpoint, [](const boost::system::error_code&
 ec) {
       if (ec.value() != boost::asio::error::connection_refused) {
         std::cout << "Expected error code " <<
 boost::asio::error::connection_refused
                   << " but got " << ec.value() << std::endl;
         } else {
            std::cout << "got error code " << ec.value() << std::endl;
         }
    });

    io_service.run();
    return 0;
 }
   }}}
 }}}

 It seems that that this behavior change to earlier boost version has
 something to-do with this commit:
 [[github.com/boostorg/asio/commit/0484963a55bf109353922e1d5fdc2a218995d9e7]]

 On linux system this example works fine

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10744>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC