blob: 6810fcd6735b1c9c56caec019fd03aa8fa5c82ac [file] [log] [blame]
Alexander Hansen10600652025-08-07 17:48:24 +02001#pragma once
2
Malik Akbar Hashemi Rafsanjani4d7b5dd2025-02-26 13:14:30 -08003#include <unistd.h>
4
5#include <array>
6#include <climits>
7#include <string>
8
9inline std::string getHostName()
10{
11 std::string hostName;
12
13 std::array<char, HOST_NAME_MAX> hostNameCStr{};
14 if (gethostname(hostNameCStr.data(), hostNameCStr.size()) == 0)
15 {
16 hostName = hostNameCStr.data();
17 }
18 return hostName;
19}