This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "" Watch "" New topic

Andrew Lowcock

Joined: Aug 13, 2003
Posts: 8
I've got a big problem.
I've have an FTP class that opens a connection to a remote machine, that has been used many times and works well in production. However ....
I've recently used the FTP component in another application which I need to show to clients, and I get when passing an IP address in as the parameter - this works fine on my Win2k dev machine, and the destination IP is that of another Win2k machine.
The code fails on a Linux machine (I can however use the account under which the application is run to manually establish a connection to the FTP server as I would expect)
Could anyone please suggest where I could start looking for the problem? I am really at a loss. Apologies if this is the wrong forum.
Many thanks
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

Well, to restate the obvious, the problem is in how Java's doing name resolution on that Linux machine. If you can ftp to the server from that same machine, using the name of the server host, and Java's failing to open a connection, using the same name, exactly (ie., both using FQDN, or neither using FQDN) then obviously they're using separate lookup mechanisms. Try to make sure they're both using exactly the same name.
The machine may be oddly configured. This is a little reminiscent of a problem I had years ago on a WinNT using a telco-return cable modem; Java and C programs generally disagreed about what the local host's IP address was. Java was clearly using a different resolution mechanism.
Well, sorry, I'm rambling. You wanted ideas for things to poke around in. Have a look in the /etc/hosts file to see if the server host's address is hard-coded there. Also look at /etc/resolv.conf to see what the machine is using for a nameserver(s). Use dig or nslookup to lookup the server both by FQDN and by hostname alone (if this is a LAN situation), and see what you get.

[Jess in Action][AskingGoodQuestions]
Andrew Lowcock

Joined: Aug 13, 2003
Posts: 8
I probably wasn't 100% clear - but I'm using the IP address, which shouldn't need to be resolved! Therefore I'm thinking more along the lines of security or the context in which the application is running.
Andrew Lowcock

Joined: Aug 13, 2003
Posts: 8
OK I solved this - I simply needed to .trim() the ip address that I obtained from the database. This extra white space seemed to be ignored on Win2k, but not on Linux....
jQuery in Action, 2nd edition
Similar Threads
Why won't my socket connect?
Challenging IP Problem
FTP site works but I'm unable to connect from Java program. I get
550 error when using Commons/Net