cleanup our cmake and build warnings (#2876)

This commit is contained in:
Tyler Wilding
2023-08-08 18:53:16 -06:00
committed by GitHub
parent 59ac52721c
commit a06a6c6416
50 changed files with 136 additions and 118 deletions
+11
View File
@@ -6,6 +6,7 @@
// clang-format off
#include "common/common_types.h"
#ifdef OS_POSIX
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <unistd.h>
@@ -178,3 +179,13 @@ bool socket_timed_out() {
return err == WSAETIMEDOUT;
#endif
}
std::string address_to_string(const sockaddr_in& addr) {
char ip_str[INET_ADDRSTRLEN]; // Buffer to hold the IP address string
// Convert binary IP address to human-readable string using inet_ntop
if (inet_ntop(AF_INET, &(addr.sin_addr), ip_str, INET_ADDRSTRLEN) == nullptr) {
// Handle the error (e.g., log, throw an exception, etc.)
return "Error: Unable to convert IP address";
}
return ip_str;
}