char* address = "<DN | IP>"; // Address can be both "ragestorm.net" or "216.118.76.209"
SOCKADDR_IN server_info = {0};
// First try interpreting the address as IP server_info.sin_addr.s_addr = inet_addr(address); if (server_info.sin_addr.s_addr == INADDR_NONE) { // Uh ho // Now it's might be an address, DNS is coming in... hostent* server_host = gethostbyname(address); if (server_host != NULL) { server_info.sin_addr = *(in_addr *)server_host->h_addr; } else { MessageBox(NULL, "Given host is not found!", NULL, MB_OK); // Exit? } }
// Fill in other fields... |