Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing pasv connection 1

Status
Not open for further replies.

amethystct

Programmer
Jan 26, 2004
21
FR
Okay who's a ftp wiz?! :)

We recently moved our servers behind a firewall and were told we had to change our feed programs to use a passive connection. I can get the mode changed to passive and it gets the file but then the connection hangs. Am I closing the connection incorrectly?

Here's a snippet of the code:
// Read bytes from server
System.out.println("Hopefully got the file!: " + getServerReply());

if (getServerReply() >= 200 && getServerReply() < 300) {
success = true;
System.out.println("Success.");
} else {
System.out.println("Not successful: " + getServerReply()); // transfer incomplete
success = false;
}
System.out.println("Close input stream");
in.close();
System.out.println("Close output stream");
fileStream.close();
System.out.println("Close the socket");
sock.close();
System.out.println("Done!");


This is the output:
150 Binary data connection for wamcon3.ok
Hopefully got the file!: 150
226 Binary Transfer complete.
 
I'm willing to bet that the subsequent calls to getServerReply are looking for more replys, rather than returning the last one.

Try stuffing the reply into an int (or whatever) and then checking the int:

int reply = getServerReply();
if (reply >= 200 && reply < 300) etc..

I'm not a whiz, but I've taken many of them...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top