Range是要下载的数据范围,对续传很重要
if(continueFlag)
{
temp.Format("Range: bytes=%d- \r\n",conLength);
bReturn=SocketSend(HTTPSocket,temp);
if(!bReturn)
{
message="发送请求失败";
return 0;
}
}
///最后一行:空行
bReturn=SocketSend(HTTPSocket,"\r\n");
if(!bReturn)
{
message="发送请求失败";
return 0;
}
///取得http头
int i;
i=GetHttpHeader(HTTPSocket,tmpBuffer);
if(!i)
{
message="获取HTTP头出错";
return 0;
}
//如果取得的http头含有404等字样,则表示连接出问题
temp=tmpBuffer;
if(temp.Find("404")!=-1)
{
return 0;
}
// 得到待下载文件的大小
filelength=GetFileLength(tmpBuffer);
return 1;
}
这样,就连接到网上的另一台机了,如何下载数据,不用多说了吧
while((num!=SOCKET_ERROR) && (num!=0))
{
num=recv (HTTPSocket
,(char FAR *)tmpBuffer
,(MAXBLOCKSIZE-1)
,0);
file.Write(tmpBuffer,num);
if(ExitFlag)
{
file.Close();
closesocket(HTTPSocket);
DownComplete=1;
m_message.CleanText();
m_message.ShowColorText(RGB(128,128,0),DLCompleteMes);
m_progress.ShowWindow(SW_HIDE);
m_stopDownload.ShowWindow(SW_HIDE);
_endthread();
}
}
基本就是这样了,本人写程序水平也不是很高,这个程序还是可以用的。。。。。
具体的程序在这里:
http://www.aitenshi.com/bbs/dispbbs.asp?boardID=3&ID=1122&page=1
http://www.aitenshi.com/bbs/dispbbs.asp?boardID=3&ID=892&page=1
和http://219.129.251.166/下载小天使_[POPGO]高达43话.rar 这里
----------------------------------------------------