C # - Ftp protocol implementation

in the Compact Framework, the Ftp protocol is not implemented, so I developed it myself.

I have a question about passive mode and the commands that should have a data channel to read the response.

In my case, I am trying to restore (RETR) a file on my FTP server, so I:

The part that works well:

  • Opencontrolchannel
  • ReadControl (banner message)
  • Senduser
  • ReadControl (pending pass?)
  • SENDPASS
  • ReadControl (greeting message)
  • Send passive
  • ReadControl (Extract IP for DataChannel)

Parts that do not work very well (but work too, see explanation below)

  • RETR myFile
  • Opendatachannel
  • ReadControl (Here I put the message "Begin Transfert" AND "Transfert complete", before reading any data!)
  • ReadData li>
  • CloseDataChannel
  • CloseControlChannel

, , "Transfert complete", , ?

, ,

"150 ASCII a.she(0 ).\r\n"

:

"226 . \r\n"

Ftp, .NET Framework, :

FtpWebResponse ftpres = (FtpWebResponse)ftp.GetResponse();
// ftpres.StatusDescription = "150 Opening ASCII mode data connection for a.she (0 bytes).\r\n" 
string res = new StreamReader(ftpres.GetResponseStream()).ReadToEnd();
// ftpres.StatusDescription = "226 Transfer complete.\r\n"

, ... !

+3
1

, , , , .

, , ( /), , , ...

(EDIT: , ( ), ...)

0

Source: https://habr.com/ru/post/1792476/


All Articles