43 URCL_LOG_ERROR(
"%s",
"Socket is already connected. Refusing to reconnect.");
63 size_t len = text.size();
64 const uint8_t* data =
reinterpret_cast<const uint8_t*
>(text.c_str());
66 return TCPSocket::write(data, len, written);
71 std::stringstream result;
73 size_t read_chars = 99;
74 while (read_chars > 0)
76 if (!TCPSocket::read((uint8_t*)&character, 1, read_chars))
79 throw TimeoutException(
"Did not receive answer from dashboard server in time. Disconnecting from dashboard " 84 if (character ==
'\n')
94 std::string response =
"ERROR";
102 throw UrException(
"Failed to send request to dashboard server. Are you connected to the Dashboard Server?");
#define URCL_LOG_ERROR(...)
bool send(const std::string &text)
std::unique_ptr< timeval > recv_timeout_
void rtrim(std::string &str, const std::string &chars="\t\n\v\f\r ")
std::string sendAndReceive(const std::string &command)
Sends a command through the socket and waits for an answer.
SocketState getState()
Getter for the state of the socket.
bool connect()
Opens a connection to the dasboard server on the host as specified in the constructor.
A specialized exception representing that communication to the tool is not possible.
Socket is connected and ready to use.
void disconnect()
Makes sure no connection to the dashboard server is held inside the object.
#define URCL_LOG_INFO(...)
Our base class for exceptions. Specialized exceptions should inherit from those.