Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.7k views
in Java FTP by (380 points)
Hi.

I'm attempting to verify connection via the connected method. However, if I try to use the condition:

if (ftp.connected()==false)

the condition is just ignored. Using "true" presents no problem. Am I going nuts, or is this a known problem?

Thanks!


K

5 Answers

0 votes
by (162k points)
I'm not sure what you mean by "ignored" for connected() == false.

The method connected() returns true if the client is currently connected to a server, or false if the client is currently disconnected. e.g. after the quit() method is called, connected() will return false.
0 votes
by (380 points)
Basically what happens is if I write code:

if (ftp.connected() == false)...

The branch of the condition is never followed, even when the connection has been dropped, or has never been active. If I write..

if (ftp.connected()==true)..

The branch of the condition is executed with no problem.

I've also just tried adding just an else statement, and that is skipped over also!
0 votes
by (51.6k points)
Am I going nuts, or is this a known problem?


No comment. :wink:

Try storing the value returned by ftp.connected() in local variable and print it out.
boolean isConnected = ftp.connected();
System.out.println(isConnected ? "Connected" : "Not connected");


- Hans (EDT)
0 votes
by (380 points)
Hello!

I've tried this.

If the client is connected, the output is "connected". If there is no connection, nothing is output at all.

Any suggestions?


Sob!
0 votes
by (51.6k points)
It must be hanging in a method call prior to connected(). Try enabling logging and posting the relevant portion here. The Developer's Guide explains how to enabled logging.

- Hans (EDT)

Categories

...