我应该从我的程序中获取此输出:
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
....
我是java的新手,我不确定问题是在目录列表的接收上还是我试图读取它的方式。问题是我得到了其他答案,但不是目录列表。这是我的输出:
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
和我的代码:
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);
提前致谢并抱歉我的英文!
答案 0 :(得分:0)
我已经解决了问题,问题是我通过被动端口发送LIST
命令,我应该通过ftp端口21发送它,就像其他命令一样,并使用被动端口只接收数据。
谢谢!