Dzień dobry,
Uczę się przepisując kod linia po linii próbuje analizować ,ale coś tu nie bangla i ja niestety nie wiem co ,tym bardziej frustrujący jest fakt ,że kod pochodzi ze strony MSDN-u :(.
#include <winsock2.h>
#include <iostream>
using namespace std;
int main(){
//init WINSOCK OBIECT
//Create a WSADATA object called
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms741563(v=vs.85).aspx
WSADATA wsadata;
//Wywołaanie WSAStartup oraz zwrocenie watrosci jako liczbe typu INT orazsprawdzenie czy nie wystąpił błąd
int wsaResult = WSAStartup(MAKEWORD(2,2),&wsadata);
if(wsaResult != 0 )
{
cout << "Kod bledu -> "<< GetLastError();
return 1;
}
//create socket for server
#define port "2705"
struct addrinfo *result = NULL, *ptr = NULL,hints; //Tu się zaczyna problem ,hints jest nie kompletne ?
ZeroMemory(&hints, sizeof (hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
error: aggregate 'main()::addrinfo hints' has incomplete type and cannot be defined|
error: 'AI_PASSIVE' was not declared in this scope|
warning: unused variable 'result' [-Wunused-variable]|
warning: unused variable 'ptr' [-Wunused-variable]|
Korzystam z Code::Blocks 16.01 32-bity,System Windows 7 Pro 64-bit , kompilator Gnu Gcc z zaznaczoną opcją kompilacji -std=c++11