#include "winsock2.h"
#include "windows.h"
#include "stdio.h"
#progma comment( lib, "WS2_32" )
int main( int argc, char **argv )
{
WSADATA wd;
WSAStartup( MAKEWORD(2,2), &wd);
char hostname[255];
char HostIP[1024];
gethostname( hostname, 255 );
hostent *pHost = gethostbyname( hostname );
// Get all the ip address of the server
if ( pHost )
{
int nIndex = 0;
while( pHost->h_addr_list[ nIndex ] )
{
memcpy( &from.sin_addr.S_un.S_addr, pHost->h_addr_list[nIndex], pHost->h_length);
sprintf( Buffer,"Host IP:%s/n", inet_ntoa( from.sin_addr ));
strcat( HostIP, Buffer);
nIndex++;
}
}
printf(HostIP);
WSACleanup();
return 0;
}