利用SOCKET下载HTTP文件(增加MD5计算)( 成功下载)
本帖最后由 BaiBai2011 于 2014-12-4 20:50 编辑增加计算下载文件MD5
*详细代码下载工程*
//http://dlsw.baidu.com/sw-search-sp/soft/d6/14991/setup_4.7.0.4087.3217271759.exe
//http://down.360safe.com/360/inst.exe
#include <stdio.h>
#include <windows.h>
#include <winsock.h>
#pragma comment(lib,"ws2_32.lib")
#include "./md5/md5.h"
#define FILE_SRV"dlsw.baidu.com"
#define FILE_DIR"sw-search-sp/soft/d6/14991/setup_4.7.0.4087.3217271759.exe"
#define USER_AGE"RookIE/1.0"
#define SAVE_FILE_DIR "DownLoad001.exe"
#define MAXLEN 1024
char strA={0};
int main(int argc, char* argv[])
{
MD5_CTX md5;
MD5Init(&md5); //初始化MD5算法
unsigned char MD5_SS={0};
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD( 1, 1 );
WSAStartup( wVersionRequested, &wsaData );
SOCKET sck = socket(AF_INET,SOCK_STREAM,NULL);
SOCKADDR_IN adr;
hostent *mhst = gethostbyname(FILE_SRV);
adr.sin_addr.S_un = ((in_addr*)mhst->h_addr_list)->S_un;
adr.sin_family = AF_INET;
adr.sin_port = htons(80);
....... 顶............ 顶。。。。
页:
[1]