title: How to catch boost asio boost::system::error_code connect exception separatly from other exceptions?
body: <p>Boost asio has such <a href="http://think-async.com/Asio/boost_asio_1_3_0/doc/html/boost_asio/reference/basic_socket/connect.html" rel="nofollow noreferrer">socket connect api</a>. I have such simple code:</p>
  
  <pre><code>try
  {
      std::string addr;
      std::string port;
      sscanf(tcpUrl.c_str(), "tcp://%[^:]:%d", &amp;addr, &amp;port);
  
      boost::asio::io_service io_service;
  
      tcp::resolver resolver(io_service);
      tcp::resolver::query query(tcp::v4(), addr.c_str(), port.c_str());
      tcp::resolver::iterator iterator = resolver.resolve(query);
  
      tcp::socket s(io_service);
      s.connect(*iterator);
      Sleep(250);
      s.close();
  }
  catch (std::exception&amp; e)
  {
      return -1;
  }
  </code></pre>
  
  <p>All I want is to try to connect and catch boost::system::error_code connect exception. Only it. I do not need to cach any more. and on it I need to return -1. How to do such thing?</p>