#if defined(__MINGW32__) #define _WIN32_WINNT 0x0501 #include #else #include #endif #include #include int main(int argc, char **argv) { char hostname[1024]; struct addrinfo *info; struct addrinfo hints; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_CANONNAME; #if defined(__MINGW32__) WSADATA wsaData; WSAStartup(0x0202, &wsaData); #endif if (gethostname(hostname, 256) == 0 && getaddrinfo(hostname, NULL, &hints, &info) == 0) { printf("%s\n", info->ai_canonname); return EXIT_SUCCESS; } return EXIT_FAILURE; }