//发送目录请求包
intReturn =  send(((CFtpClientApp*)AfxGetApp())->FtpClientSocket,(char*)myFtpControl,sizeof(FtpControl),0); if(SOCKET_ERROR == intReturn)
{
            LpStateInfo->strInfo = "发送目录请求失败!";
////////////////////////////Client//////////////////////////////////
::PostMessage(((CFtpClientApp*)AfxGetApp())->m_RightBottomView->m_hWnd,UM_OUT_PUT_RESULT,NULL,(LPARAM)LpStateInfo);
}else
{
AfxMessageBox("TEST!"); FTP_FILE_LIST_PACK *LpFile_List = new FTP_FILE_LIST_PACK;
//接收文件列表包
recv(((CFtpClientApp*)AfxGetApp())->FtpClientSocket,(char*)LpFile_List,sizeof(FTP_FILE_LIST_PACK),0);

//AfxMessageBox(LpFile_List->Buf);
//在右边列表视图中显视
::PostMessage(((CFtpClientApp*)AfxGetApp())->m_RightListView->m_hWnd,UM_RIGHT_SERVER_LIST,NULL,(LPARAM)LpFile_List);
            
delete[] (char*)LpFile_List; LpStateInfo->strInfo = "目录请求成功!";

::PostMessage(((CFtpClientApp*)AfxGetApp())->m_RightBottomView->m_hWnd,UM_OUT_PUT_RESULT,NULL,(LPARAM)LpStateInfo);
}
//////////////////////////////Server////////////////////////////
AfxMessageBox(FtpCtrl->bufData);
            //根据用户名列出目录
CString strFileName,strFileSize,strFileTime; FTP_FILE_LIST_PACK *myFileList = new FTP_FILE_LIST_PACK; myDataOption.EnumerateDirectoryDetail(strFileName,strFileSize,strFileTime,FtpCtrl->bufData);

myDataOption.EnumerateFilesDetail(strFileName,strFileSize,strFileTime,FtpCtrl->bufData);            //文件名列表
memcpy(myFileList->Buf,strFileName.GetBuffer(0),strFileName.GetLength());

memcpy(myFileList->FileSize,strFileSize.GetBuffer(0),strFileSize.GetLength());

memcpy(myFileList->FileTime,strFileTime.GetBuffer(0),strFileTime.GetLength());

myFileList->Buf[strFileName.GetLength()] = '\0';

myFileList->FileSize[strFileTime.GetLength()] = '\0';

myFileList->FileTime[strFileTime.GetLength()] = '\0';

myFileList->intLength = FILE_CONTENT_SIZE;
            //AfxMessageBox(FileList->Buf);
//响应客户端的目录请求
send(mySocket,(char*)myFileList,sizeof(FTP_FILE_LIST_PACK),0);
//AfxMessageBox(FileList->Buf);
            delete[] (char*)myFileList;

解决方案 »

  1.   

    FTP有两种模式.Passive和Active模式.如果你是内网的机子,但用了Active模式,基本上收不到数据,因为Active模式会本地绑定端口等FTP服务器来连接,但你是内网的,除非网关上做了相应的TCP端口映射等,不然无法进行数据交换.先弄清楚你自己的环境以及程序是用什么模式连接FTP服务器的.
      

  2.   

    谢谢,你,我是自已开发的FTP服务器,今天我查出来了.是服务器的问题,我接收包的时候用这个了 while(socket_error != recv..所以客户端收不到了.但我还有一个问题为什么服务器总是收到重复的包.