I am making a simple FTP client in Java using standard Java sockets. I have succeeded to connect to the server. Then I can send FTP commands like:
USER myUserName
PASS myPassword
and the output says that I am logged in to the server (I allways send the \r\n string with each command that I send to the server). When I send the command “ls” i get this response: 425 No data connection
When I log in to the server from the standard FTP client from the MS Windows terminal I can use the “ls” command and get a list of all files and folders, but it doesn´t work in my Java application.
The FTP command “HELP” also gives different output in my client and in the standard FTP client in MS Windows.
What am I doing wrong?
you need to use PORT or PASV to establish a data connection. The file list doesnt come over the control connection. You will have to read up on ftp. The commands of the ftp command in windows dont correspond 1:1 to the commands in the protocol that you have to use when implementing it yourself.