define SEND_FILE 0x20
define ACK 0x47
struct fileinfo
{
char filename[MAXPATH];
unsigned long filesize;
unsigned long crc;
} info;
char data[513];
int packs, remain,read;
openfile(&(info.filename), &(info.file_size), &(info.crc)); //this function doesn't exist, is supposed to open the file, get its size, and calc the crc
memset(data, 0, 256);
*memset=SEND_FILE;
memcpy(data+1,&info,sizeof(info));
send(socket,data,256);
recv(socket,data,256);
if(*data!=ACK)
;//transfer error
remain=info.filesize % 512 ;
packs=(info.filesize-ramain)/512;
while(packs--)
{
if(!ReadFile(file,data,512,&read,NULL))
; //read error
if(written!=pack)
; //read error
send(socket,data,512);
recv(socket,data,256);
if(*data!=ACK)
;//transfer error
}
if(!ReadFile(file,data,remain,&read,NULL))
; //read error
if(written!=pack)
; //read error
send(socket,data,remain);
recv(socket,data,256);
if(*data!=ACK)
;//transfer error
}
Enter your message below
Sign in or Join us (it's free).