客户端接收到txt文件如何没有内容
客户端接收到txt文件怎么没有内容?
代码如下:
如题,从简单的服务器上接受一个txt文档存在C盘,但是接受到的TXT怎么总是空白文档呢?
初学网络编程,请各位指点!
------解决方案--------------------
至少:while( (y = recv(conn,buff,4*1024,0) ) >0)
------解决方案--------------------
代码如下:
- C/C++ code
s.Format("Connected to server :- %s",servername); m_list.AddString(s); sprintf(buff,"GET %s\r\n\r\n",filepath); send(conn,buff,strlen(buff),0); s.Format("sending command :- GET %s to server",filepath); m_list.AddString(s); CFile f; int y; CString fname="c:\\"; fname+=filename; f.Open(fname,CFile::modeCreate | CFile::modeWrite); s.Format("starting to receive file"); m_list.AddString(s); while(y=recv(conn,buff,4*1024,0)>0) { f.Write(buff,y); } f.Close();
如题,从简单的服务器上接受一个txt文档存在C盘,但是接受到的TXT怎么总是空白文档呢?
初学网络编程,请各位指点!
------解决方案--------------------
至少:while( (y = recv(conn,buff,4*1024,0) ) >0)
------解决方案--------------------