ftp client
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   zhebin_cong
Posted On:   Friday, February 17, 2006 06:52 AM

hello all see my program following: public static void main(String args[]) { Socket socket = null; BufferedReader in = null; PrintWriter out = null; String line = null; try { socket = new Socket("myserver", 21); in = new BufferedReader(new InputStreamReader(socket .getInputStream())); out = new PrintWriter(socket.getOutputStream()); out.println("user " + "congzb"); out.println("pass " + "1qazxsw2"); out.println("pwd"); out.println("pasv"); out.println("list"); out.println("quit"); out.flush();    More>>

hello all
see my program following:


public static void main(String args[]) {
Socket socket = null;
BufferedReader in = null;
PrintWriter out = null;
String line = null;

try {
socket = new Socket("myserver", 21);
in = new BufferedReader(new InputStreamReader(socket
.getInputStream()));
out = new PrintWriter(socket.getOutputStream());
out.println("user " + "congzb");
out.println("pass " + "1qazxsw2");
out.println("pwd");


out.println("pasv");
out.println("list");

out.println("quit");
out.flush();

while ((line = in.readLine()) != null) {
System.out.println(line);
}

} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
try {
out.close();
in.close();
socket.close();
} catch (Exception fe) {
System.out.println("RESOURCE CLOSE EXCEPTION "
+ fe.getMessage());
}
}
}



the trace info as following:


331 Password required for congzb.
230-Last unsuccessful login: Fri Feb 17 02:21:26 EST 2006 on /dev/pts/1 from 9.186.23.101
230-Last login: Fri Feb 17 05:59:26 EST 2006 on ftp from ::ffff:9.186.23.101
230 User congzb logged in.
257 "/home/congzb" is current directory.
227 Entering Passive Mode (9,56,249,42,152,101)



in fact, it hang on "pasv" command. and don't give me the answer of "list" command.


why? thanks

   <<Less

Re: ftp client

Posted By:   Christopher_Koenigsberg  
Posted On:   Saturday, March 4, 2006 05:53 PM

duplicate of http://www.jguru.com/forums/view.jsp?EID=1284446

Re: ftp client

Posted By:   Lunkwill_Vroomfondel  
Posted On:   Monday, February 27, 2006 06:11 AM

this should help:



http://www.faqs.org/rfcs/rfc959.html



basically, you have to connect to the replied address (and port) for data-communication (it seems you are expecting the server to send data on the control-connection).
About | Sitemap | Contact