feat: enhance domain packet polling with hex dump for debugging and limit error logging
This commit is contained in:
@@ -197,9 +197,19 @@ void OverteClient::poll() {
|
|||||||
ssize_t r = ::recvfrom(m_udpFd, buf, sizeof(buf), 0, reinterpret_cast<sockaddr*>(&from), &fromlen);
|
ssize_t r = ::recvfrom(m_udpFd, buf, sizeof(buf), 0, reinterpret_cast<sockaddr*>(&from), &fromlen);
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
std::cout << "[OverteClient] <<< Received domain packet (" << r << " bytes)" << std::endl;
|
std::cout << "[OverteClient] <<< Received domain packet (" << r << " bytes)" << std::endl;
|
||||||
|
// Hex dump first 32 bytes for debugging
|
||||||
|
std::cout << "[OverteClient] Hex: ";
|
||||||
|
for (int i = 0; i < std::min(32, (int)r); ++i) {
|
||||||
|
printf("%02x ", (unsigned char)buf[i]);
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
parseDomainPacket(buf, static_cast<size_t>(r));
|
parseDomainPacket(buf, static_cast<size_t>(r));
|
||||||
} else if (r < 0 && errno != EWOULDBLOCK && errno != EAGAIN) {
|
} else if (r < 0 && errno != EWOULDBLOCK && errno != EAGAIN) {
|
||||||
std::cerr << "[OverteClient] UDP recv error: " << strerror(errno) << std::endl;
|
// Only log errors that aren't "would block"
|
||||||
|
static int errorCount = 0;
|
||||||
|
if (++errorCount <= 3) {
|
||||||
|
std::cerr << "[OverteClient] UDP recv error: " << strerror(errno) << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send periodic ping to domain to keep connection alive
|
// Send periodic ping to domain to keep connection alive
|
||||||
|
|||||||
Reference in New Issue
Block a user