-1

I´m supposed to get this output from my program:

Sending message to server:
Returned message: 220 (vsFTPd 2.3.5) 
Sending message to server: USER anonymous
Returned message: 331 Please specify the password.
Sending message to server: PASS
Returned message: 230 Login successful.
Sending message to server: PASV
Returned message: 227 Entering Passive Mode (90,130,70,73,114,138)
Sending message to server: LIST
Returned message: 150 Here comes the directory listing.
-rw-r--r--    1 0        0        1073741824000 Feb 19  2016 1000GB.zip
-rw-r--r--    1 0        0        107374182400 Feb 19  2016 100GB.zip
....

I´m new to java, im not sure if the problem is on the reception of the directory listing or in the way I´m trying to read it. The thing is that I get the other responses well, but not the directory listing. Here is my output:

Sending message to server: Hello server!
Returned message: 220 (vsFTPd 2.3.5)
Sending message to server: USER anonymous
Returned message: 530 Please login with USER and PASS.
Sending message to server: PASS
Returned message: 331 Please specify the password.
Sending message to server: PASV
Returned message: 230 Login successful.
Returned message: 227 Entering Passive Mode (90,130,70,73,86,199).
Port is: 22215
Sending message to server: LIST

and my code:

System.out.println("Port is: " + getPort(returnedMessage5));
Socket client2 = new Socket("speedtest.tele2.net",   getPort(returnedMessage5));
PrintWriter output2 = new PrintWriter(client2.getOutputStream(), true);
BufferedReader input2 = new BufferedReader(new InputStreamReader(client2.getInputStream()));

System.out.println("Sending message to server: LIST");
output2.println("LIST");
String returnedMessage7 = input2.readLine();
System.out.println("Returned message: " + returnedMessage7);
System.out.println(returnedMessage7);

Thanks in advance and sorry for my english!

  • 1
    I think you will need to put your `socket reading` into a different thread as there is not a *one write-one read* relationship – Scary Wombat Nov 24 '16 at 02:35
  • What exactly happens after the "Sending message to server: LIST"? Does it hang on the `input2.readLine()`? Anything useful in the FTP server log? Did you try to capture a traffic using Wireshark? – Martin Prikryl Nov 24 '16 at 07:29

1 Answers1

0

I already solved the problem, the thing is that I was sending the LIST command through the passive port, and I should have sent it through the ftp port 21, just like the other commands, and use the passive port only to receive the data. Thanks!