|
自己用网上的CFtpSockClient类写了一个ftp客户端,又在网上下了个ftp服务端的源程序,经过测试服务端正常工作,但是用我的ftp客户端连接ftp服务端的时候不能列目录!
服务端上显示502 Command not implemented
列文件列表的代码见下面:
UINT CFtpSockClient::GetFileList(CString csDirectory,CString& csFileList)
{
if(!OpenDataChannel())
return ZERO;
CString csCommand = "LIST -L";//???????????????????这条语句是什么意思??
BOOL bRetVal = SendCommand(csCommand);
GetResponse();
if(!bRetVal || GetErrorCode() != DATA_OK)
{
m_SockSrvr.Close();
return ZERO;
}
CAsyncSocket DataSocket;
// accept inbound data connection from server
if(!m_SockSrvr.Accept(DataSocket))
{
SetErrorCode(ERR_SOCK_ACCEPT);
DataSocket.Close();
m_SockSrvr.Close();
return ZERO;
}
char szBuffer[MAX_BUFFER];
int nNumBytesRead;
while(TRUE)
{
memset(szBuffer,'\0',MAX_BUFFER);
nNumBytesRead = DataSocket.Receive(szBuffer,MAX_BUFFER - 1);
if(!nNumBytesRead || nNumBytesRead == SOCKET_ERROR)
break; // ( EOF || network error )
m_FileList += szBuffer;
}
csFileList = m_FileList;
DataSocket.Close();
m_SockSrvr.Close();
GetResponse();
if(GetErrorCode() != GET_OK)
return ZERO;
return 10;
}
请高手指点迷津~~~
|
|