Go to the documentation of this file.
59 static bool open(
socket_t socket_fd,
struct sockaddr* address,
size_t address_len)
61 return ::connect(socket_fd, address,
static_cast<socklen_t
>(address_len)) == 0;
64 bool setup(
const std::string& host,
const int port,
const size_t max_num_tries = 0,
102 std::string
getIP()
const;
111 bool read(
char* character);
122 bool read(uint8_t* buf,
const size_t buf_len,
size_t&
read);
133 bool write(
const uint8_t* buf,
const size_t buf_len,
size_t& written);
153 [[deprecated(
"Reconnection time is passed to setup directly now.")]]
void
Class for TCP socket abstraction.
void setReceiveTimeout(const timeval &timeout)
Setup Receive timeout used for this socket.
TCPSocket()
Creates a TCPSocket object.
std::atomic< SocketState > state_
@ Closed
Connection to socket got closed.
std::string getIP() const
Determines the local IP address of the currently configured socket.
@ Disconnected
Socket is disconnected and cannot be used.
@ Invalid
Socket is initialized or setup failed.
static constexpr std::chrono::milliseconds DEFAULT_RECONNECTION_TIME
bool setup(const std::string &host, const int port, const size_t max_num_tries=0, const std::chrono::milliseconds reconnection_time=DEFAULT_RECONNECTION_TIME)
bool write(const uint8_t *buf, const size_t buf_len, size_t &written)
Writes to the socket.
std::atomic< socket_t > socket_fd_
void close()
Closes the connection to the socket.
bool reconnection_time_modified_deprecated_
bool read(char *character)
Reads one byte from the socket.
@ Connected
Socket is connected and ready to use.
static bool open(socket_t socket_fd, struct sockaddr *address, size_t address_len)
void setReconnectionTime(const std::chrono::milliseconds reconnection_time)
Set reconnection time, if the server is unavailable during connection this will set the time before t...
socket_t getSocketFD()
Getter for the file descriptor of the socket.
std::unique_ptr< timeval > recv_timeout_
SocketState
State the socket can be in.
std::chrono::milliseconds reconnection_time_
SocketState getState()
Getter for the state of the socket.
ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Mon May 26 2025 02:35:58