Hello, I started Winsock science, and applied the first obstacle in learning this error:
Quote:
error C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings.
|
and here the code:
Quote:
if((host=gethostbyname("localhost"))==NULL)
{
std::cout << "Nie mozna rozpoznac nazwy hosta\r\n";
WSACleanup();
system("PAUSE");
return 0;
}
|
Apparently the problem should take after changing gethostbyname to getaddrinfo () or GetAddrInfoW ()
but then appears next error
Quote:
For getaddrinfo
if ((host=getaddrinfo("localhost")) == NULL)
error C3861: 'getaddrinfo': identifier not found
IntelliSense: identifier "getaddrinfo" is undefined
For GetAddrIndoW
if ((host=GetAddrInfoW("localhost")) == NULL)
error C3861: 'GetAddrInfoW': identifier not found
IntelliSense: identifier "GetAddrInfoW" is undefined
|
How to fix these errors?
Library that I use:
Quote:
#include "stdafx.h"
#include <iostream>
#include <WinSock2.h>
#pragma comment(lib,"ws2_32.lib")
|