I have followed a tutorial on http://www.codeproject.com/KB/IP/beginningtcp_cpp.aspxt
which teaches how to use winsockets with c++, i finally managed to get my program to work, by testing wiht 127.0.0.1, i can open two process instances of my program and then make one listen on port (700) and then connect to it with the other program on port 700 with ip 127.0.0.1, i can then send messages between the two programs with no problems.
I sent the program to my friend, got his ip and told him to start listening on port 700, then i tried to connect to his ip address and port 700, the program froze for about 20 seconds (because i have it on the same thread as my window) and the connect() function returns SOCKET_ERROR here:
if (connect(g_sock, (SOCKADDR*)&target, sizeof(target)) == SOCKET_ERROR)
{
return 4;
}
I have tried other ports and i have allowed it on windows firewall.. disabled window firewall too, disabled avast.
my code is almost the same as the one in the tutorial, and i have also downloaded the one in the tutorial and i get the same erro as mine.
I am using windows 7 ultimate 32 bit