I was wondering what i am doing to make the connection not stay alive for more than about 30 seconds. I am trying to connect to googles IP on port 80 and have the program keep the connection alive for a long time. I also want it to close the socket connection every few minutes and reconnect. I am trying to do this while hiding the command prompt from the user because my friend said it is impossibleplease help me
Code:#include <iostream> #include <windows.h> #include <winsock.h> #include <stdlib.h> #include <time.h> #include <string> using namespace std; int main(int argc,char *argv[]) { int reconnect; //Hides command prompt from user HWND hwnd1 = FindWindow(NULL,argv[0]); ShowWindow(hwnd1,SW_HIDE); string ip; int port; //Define ip and port //This is yahoo.com ip on http port right now ip = "72.14.207.99"; port = 80; WSADATA sockData; WORD version; SOCKET conn; int error; version = MAKEWORD(1,1); error = WSAStartup(version, &sockData); conn = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); SOCKADDR_IN Winsock; Winsock.sin_family = AF_INET; Winsock.sin_port = htons(port); Winsock.sin_addr.s_addr = inet_addr(ip.c_str()); connect: //Connect on the socket if(connect(conn, (SOCKADDR*) &Winsock, sizeof(Winsock)) == SOCKET_ERROR) { cout << "An exception has occured (" << WSAGetLastError() << ")\n"; //Cleanup socket WSACleanup(); system("PAUSE"); return EXIT_FAILURE; } //cout << "Socket established"; //Close socket connection and reconnect Sleep(60000); //cout << "Socket reconnecting"; closesocket(conn); return EXIT_SUCCESS; system("cls"); goto connect; }



LinkBack URL
About LinkBacks
please help me 


