fix(2): use getaddrinfo() instead of gethostbyname()

pull/1858/head
Soc Virnyl S. Estela 2022-12-02 22:18:32 +08:00
parent 0540977e45
commit 55d7868f86
No known key found for this signature in database
GPG Key ID: 66772BC67FC00185
1 changed files with 8 additions and 3 deletions

View File

@ -133,6 +133,8 @@ void IPC::unregisterForIPC(EventHandler* ev_handler) {
std::string IPC::getSocket1Reply(const std::string& rq) {
// basically hyprctl
struct addrinfo ai_hints;
struct addrinfo *ai_res = NULL;
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
if (SERVERSOCKET < 0) {
@ -140,7 +142,10 @@ std::string IPC::getSocket1Reply(const std::string& rq) {
return "";
}
const auto SERVER = getaddrinfo("localhost", NULL, NULL, 0);
memset(&ai_hints, 0, sizeof(struct addrinfo));
ai_hints.ai_family = AF_UNSPEC;
ai_hints.ai_socktype = SOCK_STREAM;
const auto SERVER = getaddrinfo("localhost", NULL, &ai_hints, &ai_res);
if (!SERVER) {
spdlog::error("Hyprland IPC: Couldn't get host (2)");