Witam
piszę aplikację serwera i podczas kompilacji dostaję błąd w miejscu cpp addr.sin_addr.s_addr = inet_addr("127.0.0.1");
nie wiem czy to jest spowodowane, informacja o błędzie to:
Severity Code Description Project File Line Suppression State
'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warning serwer. Jak to naprawić? Jestem kompletnie zielony w tego typu programach a kod jest stworzony za pomocą tutoriala
//client
#pragma comment(lib, "ws2_32.lib")
#include <WinSock2.h>
#include <iostream>
int main()
{
WSAData wsaData;
WORD dllVersion = MAKEWORD(2, 1);
if (WSAStartup(dllVersion, &wsaData) != 0)
{
MessageBoxA(NULL, "Winsock start failed", "Error", MB_OK | MB_ICONERROR);
exit(1);
}
SOCKADDR_IN addr;
int addrlen = sizeof(addr);
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
addr.sin_port = htons(1111);
SOCKET sListen = socket(AF_INET, SOCK_STREAM, NULL);
bind(sListen, (SOCKADDR*)&addr, addrlen);
listen(sListen, SOMAXCONN);
SOCKET newConection;
newConection = accept(sListen, (SOCKADDR*)&addr, &addrlen);
if (newConection == 0)
{
std::cout << "Failed to accept the client's connection.\n";
}
else
{
std::cout << "Client conected!\n";
char MDTD[256] = "Welcome! This is message of the day!\n";
send(newConection, MDTD, sizeof(MDTD), NULL);
}
system("pause");
return 0;
}