ReactOS  0.4.15-dev-1150-g593bcce
gethostbyname.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <winsock2.h>
3 
4 int main( int argc, char **argv ) {
5  WSADATA wdata;
6 
7  WSAStartup( 0x0101, &wdata );
8 
9  if( argc > 1 ) {
10  struct hostent *he = gethostbyname( argv[1] );
11  if( !he ) {
12  printf( "lookup of host %s failed: %d\n", argv[1], WSAGetLastError() );
13  return 1;
14  } else {
15  printf( "Lookup of host %s returned %s\n",
16  argv[1], inet_ntoa(*((struct in_addr *)he->h_addr_list[0])) );
17  return 0;
18  }
19  } else
20  return 1;
21 }
static int argc
Definition: ServiceArgs.c:12
char ** h_addr_list
Definition: winsock.h:138
#define argv
Definition: mplay32.c:18
int main(int argc, char **argv)
Definition: gethostbyname.c:4
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
#define inet_ntoa(addr)
Definition: inet.h:100
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
Definition: getxbyxx.c:221
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
Definition: tcpip.h:125
#define printf
Definition: config.h:203