Passive FTP


Martin Robins

I know this is not really the right forum for this topic, but I figured
there are a lot of people here who may be able to provide me with an answer
to my question so I would give it a try.

About a year ago I wrote an FTP client in C#. It supported only 'Active'
mode as that was my requirement at the time; however I now need to support
'Passive' mode.

From what I can see, this simply means that you ask the server for the
details of the port to which the data connection should be made by using the
PASV command and then open an outbound connection to the server on the port
specified to transfer data across. Nothing else changes.

I have done this, and to a certain extent it works. I issue the PASV
command, open a connection to the port specified by the server and send the
data. I then close the connection. At this point, I get a 426 error,
Connection Closed, transfer aborted.

I figure I am missing something but cannot fathom what it is. Should I be
sending any additional messages to the server to indicate that the transfer
is complete?

Any help will be gratefully accepted.


Bryan Martin

This command requests the server-DTP to "listen" on a data
port (which is not its default data port) and to wait for a
connection rather than initiate one upon receipt of a
transfer command. The response to this command includes the
host and port address this server is listening on.

Martin Robins


I understand this. The server listens on a port and sends the details of
that port to the client in order that the client initiate the data
connection to that specified port - in active mode the client specifies the
port and the server connects to it.

My problem is that when I close the socket connected to the port specified
by the 227 reply after sending the data over it, for example when uploading
file to the server, the server sees this as an error and gives me a 426.

In active mode, you signify the end of the data stream by closing the port.
I am doing the same in passive mode and this is failing.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question