| QUOTE |
| ERROR The requested URL could not be retrieved While trying to process the request: GET /forums/CPPlearningcommunity/index.php?act=Attach&type=post&id=2669744 HTTP/1.1 Host: invisionfree.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive http://invisionfree.com/forums/CPPlearning...?showtopic=4491]http://invisionfree.com/forums/CPPlearning...?showtopic=4491 Cookie: CPPlearningcommunityanonlogin=-1; CPPlearningcommunityforum_read=a%3A4%3A%7Bi%3A15%3Bi%3A1121207816%3Bi%3A1%3Bi%3A1121198927%3Bi%3A6%3Bi%3A1121138159%3Bi%3A9%3Bi%3A1121199814%3B%7D; CPPlearningcommunitymember_id=1380; CPPlearningcommunitypass_hash=d973707ffc74307145c24d892bb855c5; CPPlearningcommunitysession_id=b7288cbe8ef71203c552b4f2db6b49a7; CPPlearningcommunitytopicsread=a%3A1%3A%7Bi%3A4491%3Bi%3A1121207820%3B%7D The following error was encountered: * Invalid Response The HTTP Response message received from the contacted server could not be understood or was otherwise malformed. Please contact the site operator. Your cache administrator may be able to provide you with more details about the exact nature of the problem if needed. Your cache administrator is webmaster. Generated Tue, 12 Jul 2005 22:37:11 GMT by (linuxfirewall) (version) |
| CODE |
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <errno.h> #include <stdio.h> #include <unistd.h> int main(int argc, char *argv[]) { int sock, port = 80, retval; char str[] = "GET /\r\n", addr[] = "127.0.0.1"; char buffer[65536]; struct sockaddr_in sa; FILE *f; sa.sin_family = AF_INET; sa.sin_port = htons(port); sa.sin_addr.s_addr = inet_addr(addr); memset(&(sa.sin_zero), '\0', 8); sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if(sock < 1) { sprintf(buffer, "socket() on line %d in file %s", __LINE__, __FILE__); perror(buffer); close(sock); return 1; } printf("Created socket.\n"); retval = connect(sock, (struct sockaddr *)&sa, sizeof(struct sockaddr)); if(retval < 1) { sprintf(buffer, "connect() on line %d in file %s", __LINE__, __FILE__); perror(buffer); if(errno != EINPROGRESS) { close(sock); return 1; } } printf("Connection established to the remote host.\n"); sleep(2); retval = send(sock, str, strlen(str), 0); if(retval < 1) { sprintf(buffer, "send() on line %d in file %s", __LINE__, __FILE__); perror(buffer); close(sock); return 1; } printf("Sent %d bytes of data to host.\n", retval); retval = recv(sock, buffer, 65536, 0); if(retval < 1) { sprintf(buffer, "recv() on line %d in file %s", __LINE__, __FILE__); perror(buffer); close(sock); return 1; } printf("Recieved %d bytes of data from host:\n%s", retval, buffer); printf("Saving html to file 'socktut.html'.\n"); f = fopen("socktut.html", "w+"); if(f == NULL) { sprintf(buffer, "fopen() on line %d in file %s", __LINE__, __FILE__); perror(buffer); close(sock); return 1; } fputs(buffer, f); fclose(f); printf("\nShutting down.\n"); close(sock); return 0; } |