xgboost
公共类型 | 公共成员函数 | 静态公共成员函数 | 所有成员列表
xgboost::collective::TCPSocket 类参考

用于简单通信的 TCP 套接字。更多...

#include <socket.h>

xgboost::collective::TCPSocket 的协作图
Collaboration graph

公共类型

使用 HandleT = system::SocketT
 

公共成员函数

 TCPSocket ()=default
 
auto Domain () const -> SockDomain
 返回套接字域。更多...
 
bool IsClosed () const
 
结果 GetSockError () const
 获取上次错误代码(如果有)。更多...
 
bool BadSocket () const
 检查是否发生异常。更多...
 
结果 NonBlocking (bool non_block)
 
bool NonBlocking () const
 
结果 RecvTimeout (std::chrono::seconds timeout)
 
结果 SetBufSize (std::int32_t n_bytes)
 
结果 SendBufSize (std::int32_t *n_bytes)
 
结果 RecvBufSize (std::int32_t *n_bytes)
 
结果 SetKeepAlive ()
 
结果 SetNoDelay (std::int32_t no_delay=1)
 
TCPSocket 接受 ()
 接受新连接,为新连接返回一个新的 TCP 套接字。更多...
 
结果 Accept (TCPSocket *out, SockAddress *addr)
 
 ~TCPSocket ()
 
 TCPSocket (TCPSocket const &that)=delete
 
 TCPSocket (TCPSocket &&that) noexcept(true)
 
TCPSocketoperator= (TCPSocket const &that)=delete
 
TCPSocketoperator= (TCPSocket &&that) noexcept(true)
 
HandleT const & Handle () const
 返回原生套接字文件描述符。更多...
 
结果 Listen (std::int32_t backlog=256)
 监听传入请求。应在绑定后调用。更多...
 
结果 BindHost (std::int32_t *p_out)
 将套接字绑定到 INADDR_ANY,返回操作系统选择的端口。更多...
 
auto Port () const
 
结果 Bind (StringView ip, std::int32_t *port)
 将套接字绑定到地址。更多...
 
结果 SendAll (void const *buf, std::size_t len, std::size_t *n_sent)
 发送数据,如果没有错误,所有数据都应该被发送。更多...
 
结果 RecvAll (void *buf, std::size_t len, std::size_t *n_recv)
 接收数据,如果没有错误,所有数据都应该被接收。更多...
 
auto Send (const void *buf_, std::size_t len, std::int32_t flags=0)
 使用套接字发送数据。更多...
 
auto Recv (void *buf, std::size_t len, std::int32_t flags=0)
 使用套接字接收数据。更多...
 
std::size_t Send (StringView str)
 发送字符串,格式与 RABIT 中的 Python 套接字包装器匹配。更多...
 
结果 Recv (std::string *p_str)
 接收字符串,格式与 RABIT 中的 Python 套接字包装器匹配。更多...
 
结果 关闭 ()
 关闭套接字,如果套接字未关闭,则在析构函数中自动调用。更多...
 
结果 关闭 ()
 在套接字上调用 shutdown。更多...
 

静态公共成员函数

static TCPSocket Create (SockDomain domain)
 在指定域上创建 TCP 套接字。更多...
 
static TCPSocketCreatePtr (SockDomain domain)
 

详细描述

用于简单通信的 TCP 套接字。

成员类型定义文档

◆ HandleT

构造函数和析构函数文档

◆ TCPSocket() [1/3]

xgboost::collective::TCPSocket::TCPSocket ( )
默认

◆ ~TCPSocket()

xgboost::collective::TCPSocket::~TCPSocket ( )
inline

◆ TCPSocket() [2/3]

xgboost::collective::TCPSocket::TCPSocket ( TCPSocket const &  that)
删除

◆ TCPSocket() [3/3]

xgboost::collective::TCPSocket::TCPSocket ( TCPSocket &&  that)
inlinenoexcept

成员函数文档

◆ Accept() [1/2]

TCPSocket xgboost::collective::TCPSocket::Accept ( )
inline

接受新连接,为新连接返回一个新的 TCP 套接字。

◆ Accept() [2/2]

Result xgboost::collective::TCPSocket::Accept ( TCPSocket out,
SockAddress 地址 
)
inline

◆ BadSocket()

bool xgboost::collective::TCPSocket::BadSocket ( ) const
inline

检查是否发生异常

◆ Bind()

Result xgboost::collective::TCPSocket::Bind ( StringView  IP,
std::int32_t *  端口 
)
inline

将套接字绑定到地址。

参数
IP[in]IP 地址。
端口[in,out] 如果此参数设置为 0,则让系统选择一个端口。

◆ BindHost()

Result xgboost::collective::TCPSocket::BindHost ( std::int32_t *  p_out)
inline

将套接字绑定到 INADDR_ANY,返回操作系统选择的端口。

◆ Close()

Result xgboost::collective::TCPSocket::Close ( )
inline

关闭套接字,如果套接字未关闭,则在析构函数中自动调用。

◆ Create()

static TCPSocket xgboost::collective::TCPSocket::Create ( SockDomain  )
inlinestatic

在指定域上创建 TCP 套接字。

◆ CreatePtr()

static TCPSocket* xgboost::collective::TCPSocket::CreatePtr ( SockDomain  )
inlinestatic

◆ Domain()

auto xgboost::collective::TCPSocket::Domain ( ) const -> SockDomain
inline

返回套接字域。

◆ GetSockError()

Result xgboost::collective::TCPSocket::GetSockError ( ) const
inline

获取上次错误代码(如果有)

◆ Handle()

HandleT const& xgboost::collective::TCPSocket::Handle ( ) const
inline

返回原生套接字文件描述符。

◆ IsClosed()

bool xgboost::collective::TCPSocket::IsClosed ( ) const
inline

◆ Listen()

Result xgboost::collective::TCPSocket::Listen ( std::int32_t  backlog = 256)

监听传入请求。应在绑定后调用。

默认和最小积压都设置为 256。

◆ NonBlocking() [1/2]

bool xgboost::collective::TCPSocket::NonBlocking ( ) const
inline

◆ NonBlocking() [2/2]

Result xgboost::collective::TCPSocket::NonBlocking ( bool  非阻塞)
inline

◆ operator=() [1/2]

TCPSocket& xgboost::collective::TCPSocket::operator= ( TCPSocket &&  that)
inlinenoexcept

◆ operator=() [2/2]

TCPSocket& xgboost::collective::TCPSocket::operator= ( TCPSocket const &  that)
删除

◆ Port()

auto xgboost::collective::TCPSocket::Port ( ) const
inline

◆ Recv() [1/2]

Result xgboost::collective::TCPSocket::Recv ( std::string *  p_str)

接收字符串,格式与 RABIT 中的 Python 套接字包装器匹配。

◆ Recv() [2/2]

auto xgboost::collective::TCPSocket::Recv ( void *  缓冲,
std::size_t  长度,
std::int32_t  flags = 0 
)
inline

使用套接字接收数据

参数
缓冲指向缓冲区的指针
长度缓冲区大小
标志额外标志
返回
实际接收的数据大小,如果发生错误则返回 -1

◆ RecvAll()

Result xgboost::collective::TCPSocket::RecvAll ( void *  缓冲,
std::size_t  长度,
std::size_t *  n_recv 
)
inline

接收数据,如果没有错误,所有数据都应该被接收。

◆ RecvBufSize()

Result xgboost::collective::TCPSocket::RecvBufSize ( std::int32_t *  字节数)
inline

◆ RecvTimeout()

Result xgboost::collective::TCPSocket::RecvTimeout ( std::chrono::seconds  timeout)
inline

◆ Send() [1/2]

auto xgboost::collective::TCPSocket::Send ( const void *  buf_,
std::size_t  长度,
std::int32_t  flags = 0 
)
inline

使用套接字发送数据。

参数
缓冲指向缓冲区的指针
长度缓冲区大小
标志额外标志
返回
实际发送的数据大小,如果发生错误则返回 -1

◆ Send() [2/2]

std::size_t xgboost::collective::TCPSocket::Send ( StringView  字符串)

发送字符串,格式与 RABIT 中的 Python 套接字包装器匹配。

◆ SendAll()

Result xgboost::collective::TCPSocket::SendAll ( void const *  缓冲,
std::size_t  长度,
std::size_t *  n_sent 
)
inline

发送数据,如果没有错误,所有数据都应该被发送。

◆ SendBufSize()

Result xgboost::collective::TCPSocket::SendBufSize ( std::int32_t *  字节数)
inline

◆ SetBufSize()

Result xgboost::collective::TCPSocket::SetBufSize ( std::int32_t  字节数)
inline

◆ SetKeepAlive()

Result xgboost::collective::TCPSocket::SetKeepAlive ( )
inline

◆ SetNoDelay()

Result xgboost::collective::TCPSocket::SetNoDelay ( std::int32_t  no_delay = 1)
inline

◆ Shutdown()

Result xgboost::collective::TCPSocket::Shutdown ( )
inline

在套接字上调用 shutdown。


此类的文档由以下文件生成