Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ftp回复是如何工作的_Ftp - Fatal编程技术网

ftp回复是如何工作的

ftp回复是如何工作的,ftp,Ftp,我一直在阅读FTP规范,并使用Wireshark捕获我的FTP客户端正在发送/接收的数据包,对此我有一些问题 首先,这里是来自我的FTP服务器的“连接问候语”(如FTP RFC所称): 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220-You are user number 2 of 50 allowed. 220-Local time is now 15:22. Server port: 21. 220-This

我一直在阅读FTP规范,并使用Wireshark捕获我的FTP客户端正在发送/接收的数据包,对此我有一些问题

首先,这里是来自我的FTP服务器的“连接问候语”(如FTP RFC所称):

220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 2 of 50 allowed.
220-Local time is now 15:22. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
如果在三位数后面有一个-表示这是一个多行响应。因此,似乎后续220-是不必要的,上述内容可以改写如下:

220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
You are user number 2 of 50 allowed.
Local time is now 15:22. Server port: 21.
This is a private system - No anonymous login
IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
对吗

另外,有没有限制可以排多长的队?RFC仅提及“线路长度”一次。在这里:

  A reply is defined to contain the 3-digit code, followed by Space
  <SP>, followed by one line of text (where some maximum line length
  has been specified)
他们对512的选择似乎是任意的*,然而,暂时忽略了这一点,他们的
substr($result,3,1)!=''
还会与我在本文前面所做的“连接问候语”重写中断

  • 我说这是任意的,因为数字512在RFC中出现的唯一时间是在讨论不连续文件传输的页面结构时

如有任何见解,将不胜感激-谢谢

您的多行响应是正确的。但许多服务器使用这种格式,每行行前都会重复代码。因此,不幸的是,你需要能够处理这两个问题


至于线路长度,我不知道。phpBB代码似乎并不遵循RFC

是的,您是正确的。但是,如果您只实现了linux系统上当时可用的服务器和客户端,那么如果没有3位数的编号,您的代码将无法工作。因为所有代码都遵循rfc。因此,您必须遵循rfc。

Wordpress似乎采取了更好的方法:它们将其与正则表达式匹配。但还是。。。即使在Wordpress中,你也只是一次读一个回复。但是如果你有多个回答呢?比如多个不同的220响应(即“220”与“220-”)?我想也许你只能假设你不会?我没有在FTP RFC中看到任何表示您不会的内容。您不应该使用相同的代码获得多个响应,因此请确保在下一行的开头有不同的代码时停止阅读。虽然我见过服务器为一个请求发送多个1yz代码,但这又违反了FTP规范。一次请求肯定不会得到多个2yz响应。当第一行是1yz时,您只能得到多个响应。第5.2节讨论了在多行响应的每一行前面加上响应代码,以便可以处理受保护的响应(可能是base64编码的)。自从RFC之后,许多FTP服务器总是简单地将响应代码前缀用于多行响应,因为这使得实现更简单。
do
{
    $result = @fgets($this->connection, 512);
    $response .= $result;
}
while (substr($result, 3, 1) !== ' ');