asio icon indicating copy to clipboard operation
asio copied to clipboard

Inconsistent Return of readable_pipe on Windows

Open manipuladordedados opened this issue 1 year ago • 2 comments

Currently, on Windows, readable_pipe returns ERROR_BROKEN_PIPE instead of error::misc_errors::eof. This behavior is inconsistent with other platforms.

manipuladordedados avatar Mar 07 '24 03:03 manipuladordedados

Could you provide a code sample with this error?

phprus avatar Mar 07 '24 13:03 phprus

Could you provide a code sample with this error?

int main()
{
  asio::io_context ioc;
  asio::readable_pipe pipei{ioc};
  asio::writable_pipe pipeo{ioc};

  asio::connect_pipe(pipei, pipeo);

  pipeo.write_some(asio::buffer(".", 1));
  pipeo.close();

  char buf[1];
  pipei.read_some(asio::buffer(buf));
  std::cout << buf[0] << std::endl;

  try {
    pipei.read_some(asio::buffer(buf));
  } catch (const std::exception& e) {
    std::cout << e.what() << std::endl;
  }
}

manipuladordedados avatar Mar 11 '24 01:03 manipuladordedados