|
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 |
| Result | GetSockError () const |
| get last error code if any More... | |
| bool | BadSocket () const |
| check if anything bad happens More... | |
| Result | NonBlocking (bool non_block) |
| bool | NonBlocking () const |
| Result | RecvTimeout (std::chrono::seconds timeout) |
| Result | SetBufSize (std::int32_t n_bytes) |
| Result | SendBufSize (std::int32_t *n_bytes) |
| Result | RecvBufSize (std::int32_t *n_bytes) |
| Result | SetKeepAlive () |
| Result | SetNoDelay (std::int32_t no_delay=1) |
| TCPSocket | Accept () |
| Accept new connection, returns a new TCP socket for the new connection. More... | |
| Result | Accept (TCPSocket *out, SockAddress *addr) |
| ~TCPSocket () | |
| TCPSocket (TCPSocket const &that)=delete | |
| TCPSocket (TCPSocket &&that) noexcept(true) | |
| TCPSocket & | operator= (TCPSocket const &that)=delete |
| TCPSocket & | operator= (TCPSocket &&that) noexcept(true) |
| HandleT const & | Handle () const |
| Return the native socket file descriptor. More... | |
| Result | Listen (std::int32_t backlog=256) |
| Listen to incoming requests. Should be called after bind. More... | |
| Result | BindHost (std::int32_t *p_out) |
| Bind socket to INADDR_ANY, return the port selected by the OS. More... | |
| auto | Port () const |
| Result | Bind (StringView ip, std::int32_t *port) |
| Bind the socket to the address. More... | |
| Result | SendAll (void const *buf, std::size_t len, std::size_t *n_sent) |
| Send data, without error then all data should be sent. More... | |
| Result | RecvAll (void *buf, std::size_t len, std::size_t *n_recv) |
| 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... | |
| Result | Recv (std::string *p_str) |
| Receive string, format is matched with the Python socket wrapper in RABIT. More... | |
| Result | Close () |
| Close the socket, called automatically in destructor if the socket is not closed. More... | |
| Result | Shutdown () |
| Call shutdown on the socket. More... | |
Static Public Member Functions | |
| static TCPSocket | Create (SockDomain domain) |
| Create a TCP socket on specified domain. More... | |
| static TCPSocket * | CreatePtr (SockDomain domain) |
TCP socket for simple communication.
|
default |
|
inline |
|
delete |
|
inlinenoexcept |
|
inline |
Accept new connection, returns a new TCP socket for the new connection.
|
inline |
|
inline |
check if anything bad happens
|
inline |
Bind the socket to the address.
| ip[in] | The IP address. |
| port | [in,out] Let the system choose a port if this parameter is set to 0. |
|
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.
|
inlinestatic |
|
inline |
Return the socket domain.
|
inline |
get last error code if any
|
inline |
Return the native socket file descriptor.
|
inline |
| Result xgboost::collective::TCPSocket::Listen | ( | std::int32_t | backlog = 256 | ) |
Listen to incoming requests. Should be called after bind.
Both the default and minimum backlog is set to 256.
|
inline |
|
inline |
|
inline |
| Result 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 |
|
inline |
|
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 |
|
inline |
|
inline |
Call shutdown on the socket.