我正在寫一個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)。 –