Boost C++ 库

...世界上最受推崇和专业设计的 C++ 库项目之一。 Herb SutterAndrei Alexandrescu, C++ 编码标准

PrevUpHomeNext
basic_socket::cancel (2 个重载中的 1 个)

取消与套接字关联的所有异步操作。

void cancel();

此函数导致所有未完成的异步连接、发送和接收操作立即完成,并且已取消操作的处理程序将被传递 boost::asio::error::operation_aborted 错误。

异常

boost::system::system_error

失败时抛出。

备注

在 Windows XP、Windows Server 2003 和更早版本的 Windows 上运行时,除非定义了 BOOST_ASIO_ENABLE_CANCELIO,否则调用 cancel() 总是会失败,并出现 boost::asio::error::operation_not_supported 错误。但是,CancelIo 函数有两个问题,在启用其使用之前应考虑这些问题

对于可移植的取消操作,请考虑使用以下替代方案之一

在 Windows Vista、Windows Server 2008 及更高版本上运行时,始终使用 CancelIoEx 函数。此函数没有上述问题。


PrevUpHomeNext