Opened 12 years ago

Closed 12 years ago

#4683 closed Bugs (worksforme)

Infinite loop in async_connect to 0.0.0.0:0 (boost::asio)

Reported by: Yury Podpruzhnikov <QWERTYura@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

Compiler: MSVS
Platform: MS Windows XP
BOOST_ASIO_HAS_IOCP is enabled

async_connect to 0.0.0.0:0 led to infinite loop in boost::asio.
Infinite loop is occured in select_reactor::run_thread(). It call select() (through select_reactor::run) and expect block execution by this function. But select immediately return 10038(WSAENOTSOCK). It lead to infinit use processor.

Of course connect to 0.0.0.0:0 is error, but asio must never go to infinite loop.

Change History (1)

comment:1 by chris_kohlhoff, 12 years ago

Resolution: worksforme
Status: newclosed

I cannot reproduce this problem. This test program:

#include <boost/asio/ip/tcp.hpp>
#include <iostream>

using boost::asio::ip::tcp;

void handle_connect(const boost::system::error_code& ec)
{
  std::cout << "handle_connect(" << ec.message() << ")\n";
}

int main()
{
  try
  {
    boost::asio::io_service io_service;
    tcp::socket sock(io_service);
    tcp::endpoint ep;
    std::cout << "Connecting to " << ep << "\n";
    sock.async_connect(ep, handle_connect);
    io_service.run();
  }
  catch (std::exception& e)
  {
    std::cout << "Exception: " << e.what() << "\n";
  }
}

outputs the following for me on Windows XP:

Connecting to 0.0.0.0:0
handle_connect(The requested address is not valid in its context)

Please supply a more complete test case and reopen the bug. Thanks.

Note: See TracTickets for help on using tickets.