I tried to search for it but I could'nt find any working soultions.
Nowadays Windows can detect more than ONE PROPER HARDWARE installed eternet controlled due to Hamachi, Virtual box etc etc.
Now i need to get the real IP adress of machine. When i tried do it by using gethostbyname it returned IP adress of my Hamachi client.
Now I need to find 100% solid method to receive real ip adress. Any links/tips/articles/methods really appreciate.
EDIT:
So far got this - method sugested by Remy Lebau, but it doesn't work the way I want - always returning 127.0.0.1:
int main()
{
WSADATA WSA_info;
if (WSAStartup(MAKEWORD(2,2),&WSA_info)!=0)
{
std::cout << "Error with WSA.\n";
std::cin.get();
return -1;
}
SOCKADDR_IN adress;
adress.sin_family = AF_INET;
adress.sin_port = htons(80);
adress.sin_addr.S_un.S_addr = inet_addr("213.241.88.40"); //its google's IP adress - to chech it I used ping google.com in cmd (maybe there is somethign wrong with this)
SOCKET sock;
if ((sock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP))== INVALID_SOCKET){
std::cout << "Error while creating socket." << std::endl;
closesocket(sock);
WSACleanup();
std::cin.get();
return -1;
}
if (connect(sock,(sockaddr*)&adress,sizeof(sockaddr))== SOCKET_ERROR) {
std::cout << "Couldnt connect." << std::endl;
closesocket(sock);
WSACleanup();
std::cin.get();
return -1;
}
sockaddr_in test;
int len = sizeof(test);
getsockname(sock,(struct sockaddr *) &test, &len);
std::cout << inet_ntoa(test.sin_addr);
std::cin.get();
}