Windows ( WSADATA, * nix) :)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <winsock2.h>
int main(){
struct addrinfo hints;
struct addrinfo *res=0;
int status;
WSADATA wsadata;
int statuswsadata;
if((statuswsadata=WSAStartup(MAKEWORD(2,2),&wsadata))!=0){
printf("WSAStartup failed: %d\n",statuswsadata);
}
hints.ai_family =AF_INET;
status=getaddrinfo("87.250.251.11",0,0,&res);
{
char host[512],port[128];
status=getnameinfo(res->ai_addr,res->ai_addrlen,host,512,0,0,0);
printf("Host: %s",host);
freeaddrinfo(res);
}
}
:
d:\temp\stack>ip
Host: yandex.ru
87.250.251.11 yandex.ru:
C:\Users\user>ping yandex.ru
Pinging yandex.ru [87.250.251.11] with 32 bytes of data:
Reply from 87.250.251.11: bytes=32 time=21ms TTL=56
Reply from 87.250.251.11: bytes=32 time=21ms TTL=56
Reply from 87.250.251.11: bytes=32 time=21ms TTL=56
Ping statistics for 87.250.251.11:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 21ms, Maximum = 21ms, Average = 21ms
, .