xgboost
|
TCP socket for simple communication. More...
#include <socket.h>
Public Types | |
using | HandleT = system::SocketT |
Public Member Functions | |
TCPSocket ()=default | |
auto | Domain () const -> SockDomain |
Return the socket domain. More... | |
bool | IsClosed () const |
std::int32_t | GetSockError () const |
get last error code if any More... | |
bool | BadSocket () const |
check if anything bad happens More... | |
void | SetNonBlock () |
void | SetKeepAlive () |
void | SetNoDelay () |
TCPSocket | Accept () |
Accept new connection, returns a new TCP socket for the new connection. More... | |
~TCPSocket () | |
TCPSocket (TCPSocket const &that)=delete | |
TCPSocket (TCPSocket &&that) noexcept(true) | |
TCPSocket & | operator= (TCPSocket const &that)=delete |
TCPSocket & | operator= (TCPSocket &&that) |
HandleT const & | Handle () const |
Return the native socket file descriptor. More... | |
void | Listen (std::int32_t backlog=16) |
Listen to incoming requests. Should be called after bind. More... | |
in_port_t | BindHost () |
Bind socket to INADDR_ANY, return the port selected by the OS. More... | |
auto | SendAll (void const *buf, std::size_t len) |
Send data, without error then all data should be sent. More... | |
auto | RecvAll (void *buf, std::size_t len) |
Receive data, without error then all data should be received. More... | |
auto | Send (const void *buf_, std::size_t len, std::int32_t flags=0) |
Send data using the socket. More... | |
auto | Recv (void *buf, std::size_t len, std::int32_t flags=0) |
receive data using the socket More... | |
std::size_t | Send (StringView str) |
Send string, format is matched with the Python socket wrapper in RABIT. More... | |
std::size_t | Recv (std::string *p_str) |
Receive string, format is matched with the Python socket wrapper in RABIT. More... | |
void | Close () |
Close the socket, called automatically in destructor if the socket is not closed. More... | |
Static Public Member Functions | |
static TCPSocket | Create (SockDomain domain) |
Create a TCP socket on specified domain. More... | |
TCP socket for simple communication.
|
default |
|
inline |
|
delete |
|
inlinenoexcept |
|
inline |
Accept new connection, returns a new TCP socket for the new connection.
|
inline |
check if anything bad happens
|
inline |
Bind socket to INADDR_ANY, return the port selected by the OS.
|
inline |
Close the socket, called automatically in destructor if the socket is not closed.
|
inlinestatic |
Create a TCP socket on specified domain.
|
inline |
Return the socket domain.
|
inline |
get last error code if any
|
inline |
Return the native socket file descriptor.
|
inline |
|
inline |
Listen to incoming requests. Should be called after bind.
std::size_t xgboost::collective::TCPSocket::Recv | ( | std::string * | p_str | ) |
Receive string, format is matched with the Python socket wrapper in RABIT.
|
inline |
receive data using the socket
buf | the pointer to the buffer |
len | the size of the buffer |
flags | extra flags |
|
inline |
Receive data, without error then all data should be received.
|
inline |
Send data using the socket.
buf | the pointer to the buffer |
len | the size of the buffer |
flags | extra flags |
std::size_t xgboost::collective::TCPSocket::Send | ( | StringView | str | ) |
Send string, format is matched with the Python socket wrapper in RABIT.
|
inline |
Send data, without error then all data should be sent.
|
inline |
|
inline |
|
inline |