neku
Codeur roumain
Code:
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
SOCKET sock;
SOCKADDR_IN sin;
WSADATA WSAData;
const char * GetIP(const char * Host)
{
[indent]WSADATA WSAData;
WSAStartup(MAKEWORD(2,0), &WSAData);
struct hostent * host = gethostbyname(Host);
if (host)
{
[indent]WSACleanup();
return inet_ntoa(*((struct in_addr * )host->h_addr));
[/indent]}
else
{
[indent]WSACleanup();
return Host;
[/indent]}
[/indent]}
char* IP_Google = GetIP(www.google.fr);
pour obtenir l'ip du nom de domaine de google
char* IP_Local = GetIP(NULL);
pour obtenir l'ip locale. (pas testé avec plusieur adapter réseau)