CSocket传送大文件问题
服务器端代码
CFile myFile;
myFile.Open("D:\\test.txt", CFile::modeRead | CFile::typeBinary);
int myFileLength = myFile.GetLength(); // Going to send the correct File Size
sockRecv.Send(&myFileLength, 4); // 4 bytes long
byte* data = new byte[myFileLength];
myFile.Read(data, myFileLength);
//sockRecv.Send(data, myFileLength); //Send the whole thing now
for(int i=0;i<=myFileLength;i+=1024)
{
sockRecv.Send(data+i,1024); //Send the whole thing now
Sleep(10);
}
if(myFileLength%1024!=0)
sockRecv.Send(data+myFileLength-myFileLength%1024,myFileLength%1024);