争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

2台机器间传输文件的函数

时间:2024/7/16作者:未知来源:争怎路由网人气:

CFile::typeBinary);   
    
    
int myFileLength = myFile.GetLength(); // Going to send the correct F   
ile 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   
    
myFile.Close();   
delete data;   
    
sockRecv.Close();   
}   
    
Client(接收)端:   
void GetFile(){   
    
#define PORT 34000 /// Select any free port you wish   
    
AfxSocketInit(NULL);   
CSocket sockClient;   
sockClient.Create();   
    
// "127.0.0.1" is the IP to your server, same port   
sockClient.Connect("127.0.0.1", PORT);  int dataLength;   
    
sockClient.Receive(&dataLength, 4); //Now we get the File Size first   
    
    
byte* data = new byte[dataLength];   
sockClient.Receive(data, dataLength); //Get the whole thing   
    
CFile destFile("C:\\temp\\ANYFILE.EXE",   
  CFile::modeCreate

关键词:2台机器间传输文件的函数




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版