Boost C++ 库

…世界上最受推崇和设计精良的C++库项目之一。 Herb SutterAndrei Alexandrescu,《C++编码规范

basic_seq_packet_socket::shutdown(共2个重载函数中的第2个) - Boost C++ 函数库
PrevUpHomeNext

继承自 basic_socket。

禁用套接字上的发送或接收。

void shutdown(
    shutdown_type what,
    boost::system::error_code & ec);

此函数用于禁用发送操作、接收操作或两者都禁用。

参数

what

确定哪些类型的操作将不再允许。

ec

用于指示发生何种错误(如果有)。

示例

关闭套接字的发送端

boost::asio::ip::tcp::socket socket(my_context);
...
boost::system::error_code ec;
socket.shutdown(boost::asio::ip::tcp::socket::shutdown_send, ec);
if (ec)
{
  // An error occurred.
}

PrevUpHomeNext