CWD /CitiPro_Support
250 CWD command successful.
PORT 192,168,18,107,4,76
500 'POPORT 218,18,151,3,4,76': command not understood
PORT 192,168,18,107,4,76
PORT 192,168,18,107,4,76
PORT 192,168,18,107,4,76
PORT 192,168,18,107,4,76是不是上面调试的命令格式有误啊?
250 CWD command successful.
PORT 192,168,18,107,4,76
500 'POPORT 218,18,151,3,4,76': command not understood
PORT 192,168,18,107,4,76
PORT 192,168,18,107,4,76
PORT 192,168,18,107,4,76
PORT 192,168,18,107,4,76是不是上面调试的命令格式有误啊?
command not understood '未知的命令
可以肯定的一点,你命令有错误,你不把代码贴出来,怎么帮你?
如果网路很顺畅的话,就不会出现这种情况;代码非常长,贴出经常出错的函数,要是出错的话,应该重点在贴出的第二个函数:ublic Function EnumFiles(oFiles As CFtpFiles) As Boolean
'********************************************************************************
'该函数的功能是获得当前目录下面的所有目录和文件
'********************************************************************************Dim bDataConnectionEstablished As Boolean'On Error GoTo EnumFiles_Err_Handler m_bBusy = True If m_bPassiveMode Then
'如果是被动模式
bDataConnectionEstablished = ProcessPASVCommand
Else
'否则发送port命令
bDataConnectionEstablished = ProcessPORTCommand
End If
If bDataConnectionEstablished Then
RaiseEvent StateChanged(FTP_RETRIEVING_DIRECTORY_INFO)
If ProcessLISTCommand Then
m_objTimeOut.StartTimer
Do
DoEvents
'如果超时
If m_objTimeOut.Timeout Then
m_LastError = ERROR_FTP_USER_TIMEOUT
'如果已经从服务器获得全部信息
If GetResponseCode(Left(m_strLastServerResponse, 3)) = FTP_RESPONSE_CLOSING_DATA_CONNECTION Then
Set oFiles = GetFileList(m_strDataBuffer)
EnumFiles = True
RaiseEvent StateChanged(FTP_DIRECTORY_INFO_COMPLETED)
m_strDataBuffer = ""
End If
Exit Do
End If
'如果已经关闭连接,表示也已经成功得到信息
If wscData.State = sckClosing Or wscData.State = sckClosed Then
Set oFiles = Nothing
Set oFiles = GetFileList(m_strDataBuffer)
EnumFiles = True
RaiseEvent StateChanged(FTP_DIRECTORY_INFO_COMPLETED)
m_strDataBuffer = ""
Exit Do
End If
Loop
m_objTimeOut.StopTimer
Else
'产生错误,不能建立连接
End If
Else
'产生错误,不能建立连接
End IfExit_Label:
m_bBusy = False
Exit FunctionEnumFiles_Err_Handler:
Err.Raise vbObjectError + 1000 + Err.Number, "CFtpConnection.EnumFiles", Err.Description
GoTo Exit_Label
End FunctionPrivate Function ProcessPORTCommand() As Boolean
'该函数的功能是发送port命令,为数据连接指定一个ip地址和本地地址
Dim intPort As Integer
Dim strIPAddress As String
Dim colIPAddresses As New Collection
Dim strSend As String
Dim strData As String
Dim i As Integer
On Error Resume Next
RaiseEvent StateChanged(FTP_ESTABLISHING_DATA_CONNECTION)
Do
intPort = GetFreePort
If wscData.State <> sckClosed Then wscData.Close
wscData.LocalPort = intPort
'设置本地端口
wscData.Listen
If Not Err Then Exit Do
Loop
On Error GoTo ProcessPORTCommand_Err_Handler
'
strIPAddress = CStr(wscControl.LocalIP)
'
strSend = "PORT " & Replace(strIPAddress, ".", ",")
strSend = strSend & "," & intPort \ 256 & "," & (intPort Mod 256)
'
strSend = strSend & vbCrLf
'错误的协议和连结状态for 发送命令
If FtpGetLastError = ERROR_FTP_WINSOCK_BadState Then Connect
wscControl.SendData strSend '向服务器发送port命令
Debug.Print Left(strSend, Len(strSend) - 2)
RaiseEvent ReplyMessage(Left(strSend, Len(strSend) - 2) & vbCrLf)
m_objTimeOut.StartTimer
Do
DoEvents
'
If m_objTimeOut.Timeout Then
m_LastError = ERROR_FTP_USER_TIMEOUT
Exit Do
End If
'
If InStr(1, m_strWinsockBuffer, vbCrLf) > 0 Then
strData = m_strWinsockBuffer
m_strWinsockBuffer = ""
Exit Do
End If
Loop
m_objTimeOut.StopTimer
If GetResponseCode(strData) = FTP_RESPONSE_COMMAND_OK Then
ProcessPORTCommand = True
RaiseEvent StateChanged(FTP_DATA_CONNECTION_ESTABLISHED)
Else
' If i < 4 Then
' i = i + 1
' GoTo mylable
' End If
' '重复三次,防止超时出错
ProcessFtpResponse GetResponseCode(strData)
End If
Exit_Label:
Exit FunctionProcessPORTCommand_Err_Handler:
' MsgBox ""
If Not ProcessWinsockError(Err.Number, Err.Description) Then
Err.Raise vbObjectError + 1000 + Err.Number, "CFtpConnection.ProcessPORTCommand", Err.Description
End If
GoTo Exit_Label
End Function