When I try to download a set of files using stream sockets on an HTTP protocol, it is only the first Receives data from the file. Try downloading.
Accept a loop like the following ...
char * file = (char *) malloc (enough_space); Four pages [] = {"www.foobar.com"}; {Sprintf (file, "file% i.html", n) for (int n = 0; n & lt; 10; n ++); Fopen (file, "wb"); Sprintf (Request, "GET% s HTTP / 1.1 \ nHost:% s \ n \ n", file, page); Write (socket, request, strollon (request)); Read_file (output_file); Fclose (output_file); }
Where a connection has been established first.
This code will give me the file 1.html, its header from the server .. but only the first file, and this puzzle me .. what would I have to do to get them all? Thanks, forward.
HTTP was designed so that only one file could be downloaded on a TCP connection. To download multiple files from a TCP connection, you can use HTTP pipelining. You can also read more here:
Or you can use one of the many libraries that handle it, and many other HTTP alerts for you: libcurl, libsoup ...
Comments
Post a Comment