Linux C用http协议下载文件
#include <stdio.h> #include <stdlib.h> #include <limits.h> #include <sys/time.h> #include <sys/select.h> #include <netdb.h> #include <ctype.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <unistd.h> #include <netinet/in.h> #define RECV_BUF_LEN (1024*100) struct hostent *host; char domain[256] = {0}; int port = 0; int ret_status(char *recv_buf) { if(NULL == recv_buf) { printf("recv_buf is NULL\n"); return -1; } int http_status = 0; char line[256] = {0} ; char *rest ; rest = strstr(recv_buf,"\r\n"); if ( rest != NULL) { memcpy(line,recv_buf,rest