Boost C++ 库

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

basic_raw_socket::remote_endpoint (2 个重载中的 2 个) - Boost C++ 函数库
PrevUpHomeNext

继承自 basic_socket。

获取套接字的远程端点。

endpoint_type remote_endpoint(
    boost::system::error_code & ec) const;

此函数用于获取套接字的远程端点。

参数

ec

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

返回值

一个表示套接字的远程端点的对象。如果发生错误,则返回一个默认构造的端点对象。

示例
boost::asio::ip::tcp::socket socket(my_context);
...
boost::system::error_code ec;
boost::asio::ip::tcp::endpoint endpoint = socket.remote_endpoint(ec);
if (ec)
{
  // An error occurred.
}

PrevUpHomeNext