我尝试从远程网络服务器下载tar文件,但我只获取虚假数据。每次运行时其他bytesize并用HTTP标头:ANSI C从服务器下载文件
//now it is time to receive the page
memset(buf, 0, sizeof(buf));
FILE *fp;
if ((fp = fopen(FILENAME, "wb"))==NULL) {
perror("Error open file");
}
else {
while((tmpres = recv(xmlsock, buf, 65536, 0)) > 0){
fwrite(buf, sizeof(buf), 1, fp);
memset(buf, 0, tmpres);
}
}
if(tmpres < 0) {
perror("Error receiving data");
}
fclose(fp);
close(xmlsock);
我送头是:
GET /updates/xxxxx.tar HTTP/1.1
Host: www.yyyyyyyy.de
User-Agent: HTMLGET 1.1
Connection: close
任何人可以帮助我吗?
谢谢!这是我的问题。我知道了! – user2372814