#include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include int main(int argc, char *argv) { struct hostent *hp; struct sockaddr_in addr; int fd; hp = gethostbyname("www.google.com"); fd = socket(AF_INET, SOCK_STREAM, 0); addr.sin_port = htons(80); addr.sin_family = AF_INET; bcopy((char*)hp->h_addr, (char*)&addr.sin_addr, hp->h_length); connect(fd, (struct sockaddr *)&addr, sizeof(addr)); // open www.google.com:80 // make request //char *request; //sprintf(request, "GET /index.html\nKeep-Alive: 300\nConnection: keep-alive\n\n"); write(fd, "GET /index.html\r\nKeep-Alive: 900\r\nConnection: keep-alive\r\n\r\n", 500); // receive shit char buf[1024]; recv(fd, buf, sizeof(buf), 0); printf(buf); printf("end\n"); // close(fd); }