23 #include <sys/socket.h> 24 #include <sys/types.h> 56 virtual bool open(
int socket_fd,
struct sockaddr* address,
size_t address_len)
60 virtual void setOptions(
int socket_fd);
62 bool setup(std::string& host,
int port);
98 std::string getIP()
const;
107 bool read(
char* character);
118 bool read(uint8_t* buf,
const size_t buf_len,
size_t& read);
129 bool write(
const uint8_t* buf,
const size_t buf_len,
size_t& written);
141 void setReceiveTimeout(
const timeval& timeout);
151 reconnection_time_ = reconnection_time;
std::atomic< SocketState > state_
Connection to socket got closed.
std::atomic< int > socket_fd_
SocketState
State the socket can be in.
std::unique_ptr< timeval > recv_timeout_
void setReconnectionTime(std::chrono::seconds reconnection_time)
Set reconnection time, if the server is unavailable during connection this will set the time before t...
Socket is initialized or setup failed.
Socket is disconnected and cannot be used.
SocketState getState()
Getter for the state of the socket.
Class for TCP socket abstraction.
Socket is connected and ready to use.
virtual bool open(int socket_fd, struct sockaddr *address, size_t address_len)
std::chrono::seconds reconnection_time_
int getSocketFD()
Getter for the file descriptor of the socket.