So I am trying to build up a Server-Client program in C++. I am trying to make a more "Friendly" "Connect" function. But, I am having a problem. I am getting this error when I am running it.
Error 1 error C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
This is the Connect()
function that it returns the error on:
bool Connect(std::string ip, TPort port) {
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr(ip.c_str());
clientService.sin_port = htons(port);
SOCKET connecter = connect(handle,
(SOCKADDR *)& clientService,
sizeof(clientService));
return (connecter == 0);
}
I searched a bit in the internet and didn't find something that helps me. The error comes from the line:
clientService.sin_addr.s_addr = inet_addr(ip.c_str());
I am using windows API , and Visual Studio 2013