//Client to Aaron's fileserver //Author $ Dylan Johnston //Connect $ bitforge.redirectme.net:404 //Notes $ Win-sock-two #include #include #include #include #include #include using namespace std; const string DEBUG = "[debug]: "; //just to make things clear in the console :) char serverAddress[128]; int main() { int iResult; WSADATA wsaData; //start winsock iResult = WSAStartup(MAKEWORD(2,2), &wsaData); if (iResult != 0) { cout << DEBUG << "failed" << iResult << "\n"; } else { if (iResult == 0) { cout << DEBUG << "success" << "\n"; cout << DEBUG << "starting up winsock\n"; // Create a SOCKET for connecting to server SOCKET ConnectSocket; ConnectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (ConnectSocket == INVALID_SOCKET) { cout << DEBUG << "error " << WSAGetLastError(); WSACleanup(); } // The sockaddr_in structure specifies the address family, // IP address, and port of the server to be connected to. sockaddr_in clientService; clientService.sin_family = AF_INET; clientService.sin_addr.s_addr = inet_addr( "209.85.135.103" ); clientService.sin_port = htons( 80 ); addrinfo *aiList = 0; addrinfo aiHints = {0}; aiHints.ai_family = AF_UNSPEC; aiHints.ai_socktype = SOCK_STREAM; aiHints.ai_protocol = IPPROTO_TCP; cout << "address: "; cin >> serverAddress; if (getaddrinfo( serverAddress, "3690", &aiHints, &aiList ) != 0 ) { closesocket( ConnectSocket ); WSACleanup(); return 0; } // Connect to server. if ( connect( ConnectSocket, (SOCKADDR*) &clientService, sizeof(clientService) ) == SOCKET_ERROR) { cout << DEBUG << "failed connection" << "\n"; WSACleanup(); system("Pause"); return 0; } cout << DEBUG << "connected!"; WSACleanup(); //that's 1 } //that's 2 } ALOT OF THINGS! } //that's 3 system("Pause"); return 0; }