- #include <string>
- #include <iostream>
- #include <stdio.h>
- #include <winsock.h>
- #include <conio.h>
- using namespace std;
- #pragma comment("ws2_32.lib")
- string host2ip(const string& strdomain);
- void save2file(char *buffer,const string& filename);
- int getlength(const string& sheader);
- bool getstatus(const string& sheader);
- int getleftlength(const string& sheader);
- void sethttphead(const string& file,const string& server);
- int port = 80;
- int error=0;
- string serveraddr;
- int i = 0;
- const int BUFFER_SIZE = 1024;
- char buffer[BUFFER_SIZE] = {0};
- char msg[BUFFER_SIZE];
- FILE *f;
- const string file = "/BT/200801/3/117906.torrent";
- const string url = "www.supbt.com";
- const string filename = "117906.torrent";
- int main(void)
- {
- int r;
- WSADATA wsa;
- SOCKET sock;
- struct sockaddr_in sin;
- f = fopen(filename.c_str(),"ab");
- sethttphead(file,url);
Linux下Socket写http协议下载文件代码以及说明
最新推荐文章于 2024-05-10 13:36:53 发布