我正在写一个FTP服务器(用Qt/C++),现在我用“200 Ok”改为“TYPE A”,但我真的把它和“类型I“ - 文件按原样发送。在FTP服务器中实现“TYPE A”
我应该如何正确实施TYPE A?以文本模式而不是二进制模式打开文件是否够用?
此外,我认为SIZE方法应该比在磁盘上返回文件大小更复杂,它应该读取它并执行文本替换,并返回大小的方式?
编辑:在回答评论,这里是从the RFC959 spec相关摘录:
3.1.1.1. ASCII TYPE This is the default type and must be accepted by all FTP implementations. It is intended primarily for the transfer of text files, except when both hosts would find the EBCDIC type more convenient. The sender converts the data from an internal character representation to the standard 8-bit NVT-ASCII representation (see the Telnet specification). The receiver will convert the data from the standard form to his own internal form. In accordance with the NVT standard, the <CRLF> sequence should be used where necessary to denote the end of a line of text. (See the discussion of file structure at the end of the Section on Data Representation and Storage.) Using the standard NVT-ASCII representation means that data must be interpreted as 8-bit bytes. The Format parameter for ASCII and EBCDIC types is discussed below.
你是什么意思'我返回成功的类型A''? “我应该如何正确实施A型”是什么意思?你的问题目前假设了太多的知识,而不是像我的那样。 ;) – lpapp
这就是命令的命名方式。在控制连接中写入“TYPE A”以指定ASCII,“TYPE I”代表Image - 表示二进制。 – sashoalm
@LaszloPapp:确定存在:在RFC959第27页中描述了类型A(ASCII),I(图像)和E(EBCDIC)。 –