3

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

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

In my case, I'm trying to retrieve (RETR) a file on my FTP Server, So I do :

Part that works well :

  • OpenControlChannel
  • ReadControl (Banner Message)
  • SendUser
  • ReadControl (Awaiting pass?)
  • SendPass
  • ReadControl (Welcome Message)
  • SendPassive
  • ReadControl (Extract IP for the DataChannel)

Parts that doesn't work very well (but work too, see explanation below)

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

Problem is, I need just to open data channel to have the message "Transfert complete" even if I haven't read any data on the stream, is this behavior normal?

For me, when I open the data channel I should just receive

"150 Opening ASCII mode data connection for a.she (0 bytes).\r\n"

Then once the read operation done :

"226 Transfer complete.\r\n"

When I look to the classic Ftp protocol used in the .NET Framework, it is the case :

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"

Hope I'm clear enough... Thanks !

Arnaud F.
  • 8,252
  • 11
  • 53
  • 102

1 Answers1

0

I think this behavior is normal, it pre-load data in a cache on server side and send the message in order to say data are available and loaded.

This because when data channel is between 2 servers (and not client/server mode), the user should now when transfer is done, so it only take a look on this cache...

(EDIT : In some case it appears that I got messages in the good order (only once data read), strange...)

Arnaud F.
  • 8,252
  • 11
  • 53
  • 102