该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
#include
struct cfgmain
{
long size;
long Received;
char website[1000];
}
int LoadWSA()
{
WSADATA wd;
if(WSAStartup(0x0101,&wd))
{
return -1;
}
return 0;
}
void downThread(char *url,int threadID,int rangeFrom,int rangeUntil,FILE *cfg,FILE *fp)
{
char *oriURL=url;
char *ReadWriteBuf=(char*)malloc(20000);
cfgmain cfgfile;
char bufferSend[65535];
char *bufferRecv=(char*)malloc(65535);
if(strstr(url,"http://"))
{
url=url+sizeof("http://");
}
int lengthOfWeb;
for(lengthOfWeb==0;lengthOfWeb<=sizeof(url);lengthOfWeb++)
{
if(url[lengthOfWeb]=='/')
{
break;
}
}
char name[255];
memcpy(name,url,lengthOfWeb);
SOCKET sock=::socket(2,SOCK_STREAM,0);
struct hostent *h;
h=gethostbyname(name);
if(h==0)
{
printf("ThreadID :#%d ERROR:%d The thread will exit!\n",threadID,WSAGetLastError());
return;
}
struct sockaddr_in saddr;
memcpy(&saddr.sin_addr,h->h_addr_list,h->h_length);
saddr.sin_port=htons(80);
saddr.sin_family=AF_INET;
if(connect(sock,(sockaddr*)&saddr,sizeof(sockaddr)))
{
printf("ThreadID :#%d ERROR:%d The thread will exit!\n",threadID,WSAGetLastError());
return;
}
url=url+sizeof(h->h_length)+1;
unsigned int temp;
if(cfg==0)
{
sprintf(bufferSend,"GET /%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n",url,h->h_name);