--- a/sources/network/rconsession.cpp Wed Jan 27 19:01:37 2021 +0200 +++ b/sources/network/rconsession.cpp Wed Jan 27 19:27:23 2021 +0200 @@ -42,10 +42,10 @@ m_adminCount(0), m_interface(nullptr) { - if (not m_socket.set_blocking(false)) + std::stringstream errors; + if (not m_socket.set_blocking(false, errors)) { - fprintf(stderr, "unable to set socket as non-blocking: %s\n", - m_socket.error_string().data()); + fprintf(stderr, "unable to set socket as non-blocking: %s\n", errors.str().data()); exit(EXIT_FAILURE); } } @@ -80,9 +80,15 @@ // ------------------------------------------------------------------------------------------------- // -void RCONSession::send(const ByteArray& packet) +bool RCONSession::send(const ByteArray& packet) { - m_socket.send(m_address, packet); + std::stringstream errors; + const bool result = m_socket.send(m_address, packet, errors); + if (not result) + { + this->m_interface->printError("Network error: %s\n", errors.str().data()); + } + return result; } // ------------------------------------------------------------------------------------------------- @@ -112,8 +118,14 @@ } } - for (Datagram datagram; m_socket.read(datagram);) + std::stringstream errors; + for (net::Datagram datagram; m_socket.read(datagram, errors);) { + if (errors.tellp() > 0) + { + m_interface->printError("Network error: %s\n", errors.str().data()); + errors = {}; + } // Only process packets that originate from the game server. if (datagram.address == m_address) handlePacket(datagram.message); @@ -268,7 +280,7 @@ // ------------------------------------------------------------------------------------------------- // -UDPSocket* RCONSession::getSocket() +net::UDPSocket* RCONSession::getSocket() { return &m_socket; } @@ -379,7 +391,7 @@ } else { - m_interface->print("This server does not support tab-completion\n", m_serverProtocol); + m_interface->print("This server does not support tab-completion\n"); } }