ReactOS 0.4.16-dev-106-g10b08aa
gethostbyname.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <winsock2.h>
3
4int 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
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
int main()
Definition: test.c:6
#define printf
Definition: freeldr.h:97
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
Definition: getxbyxx.c:221
#define inet_ntoa(addr)
Definition: inet.h:100
#define argv
Definition: mplay32.c:18
char ** h_addr_list
Definition: winsock.h:138
Definition: tcpip.h:126
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112