一年多前,我在 c# 中发现了一个 ftp 客户端类,并且一直在每晚上传文件的过程中使用它。几天前,我们开始遇到超时问题。我对此并不精通,所以我不确定它为什么会这样做。
当程序开始上传文件时,它会检查它是否已登录,如果没有,它会调用 login 方法。在那个方法中就是这个代码块。
if (this.resultCode != 230)
{
this.sendCommand("PASS " + password);
if (!(this.resultCode == 230 || this.resultCode == 202))
{
this.cleanup();
throw new FtpException(this.result.Substring(4));
}
}
在说 this.sendCommand("PASS"... 的行上,它进入了这段代码。
private void sendCommand(String command)
{
if (this.verboseDebugging) Debug.WriteLine(command, "FtpClient");
Byte[] cmdBytes = Encoding.ASCII.GetBytes((command + "\r\n").ToCharArray());
clientSocket.Send(cmdBytes, cmdBytes.Length, 0);
this.readResponse();
}
如果我让程序运行,它会超时。但是,如果我将它单步执行到 sendCommand 方法中,它会执行得很好。有谁知道为什么当我逐步完成它时它会正常工作?我们这边没有任何改变,我被告知客户端没有任何改变,所以我很难过。谢谢。