I've just started to learn WinSock. I started by reading this article: https://msdn.microsoft.com/en-us/library/windows/desktop/bb530750(v=vs.85).aspx And i did what I was wrote to do.
But I can not connect, every time I run this program i got same error:
Connection timed out. A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond.
My code is here: http://pastebin.com/0THqWKXv
Could you tell me what did I wrong? How to repair my code?
PS. The IP adress is to google.pl
PS2. Actual code responsible for connection:
iResult = connect(ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
while (iResult == SOCKET_ERROR){
cout << "Blad ustanowienia polaczenia:\t" << WSAGetLastError() << endl;
ptr = ptr->ai_next;
iResult = connect(ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
}