aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes Unable to connect to Windows Machine Using FTPClient... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Unable to connect to Windows Machine Using FTPClient..." Watch "Unable to connect to Windows Machine Using FTPClient..." New topic
Author

Unable to connect to Windows Machine Using FTPClient...

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 471
Hi Everyone,

I am trying to connect to a Windows machine from a Sun OS! But when i run the code i get the error:

j

I can understand what the error means but dont know how to resolve it.


My Code is:


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16479
    
    2

Somnath Mallick wrote: I can understand what the error means but dont know how to resolve it.


So what does the error mean? It would be a good idea if you posted that -- you might not really understand it after all. (Since you posted some code, that suggests you might not understand it.)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Can you access the FTP site with the username and password using a regular FTP client like FileZilla?

To be honest, I doubt it - the FTP (command) port is 21, not 22. 22 is used for SSH, and you can't use the FTP protocol for that.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 471
Well one thing i understood is that the connection is refused maybe because I am using the wrong IP address, or incorrect user name and password. But not more than that!

I tried with 21 as well and it didn't work and i got the same connection refused exception. I posted the code so that you can check out what went wrong. Could it be a firewall issue?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35223
    
    7
Rob Prime wrote:Can you access the FTP site with the username and password using a regular FTP client like FileZilla?


Android appsImageJ pluginsJava web charts
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 471
Oops forgot to write that!

I tried it through filezilla but didn't connect. Actually I am using an office PC. Many people have used that PC. Also my account is not an administrator account. I tried to connect using my Login Credentials! Do i need the Admin username and password for this?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35223
    
    7
So the problem then has nothing to do with the Java code - it is a general connection problem?
Antany Vasanth
Ranch Hand

Joined: Jan 28, 2009
Posts: 43
Hi Somnath

Please verify the ftp services are enabled in your windows machine.

For enabling FTP services in windows go through the following link

http://windowsitpro.com/article/articleid/38646/how-can-i-install-the-ftp-service-under-windows-xp.html

Regards
Antany.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 471
I followed the instruction and completed this task:



A. XP includes a built-in FTP service component that lets FTP clients connect to the machine and read or write files; however, this service doesn't install by default. To install the FTP service, perform the following steps:

1. Start the Control Panel Add/Remove Programs applet (go to Start, Control Panel, then click Add/Remove Programs).
2. Select Add/Remove Windows Components.
3. Select Internet Information Services (IIS), then click Details.
4. Select the File Transfer Protocol (FTP) Service check box, then click OK.
5. Click OK to close all dialog boxes.


But still i get the connection refused issue.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

You haven't set up users or anything yet.

Also, you may prefer the FileZilla FTP server over the IIS one. It's a bit easier to work with, especially with user accounts. IIS can only use the built-in Windows users, if I recall correctly.
Antany Vasanth
Ranch Hand

Joined: Jan 28, 2009
Posts: 43
Hi Somnath,

In your windows machine open command prompt and type "ftp localhost". If it prompts for user name then that means you have successfully enabled the FTP Services and the problem is with the communication between two machines.

Try to ping your windows machine from the Sun OS machine from where you are executing the Java program. Also check your firewall settings.

Kindly ensure to use port "21"(Defalut FTP Port)

Regards,
Antany
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 471
Apologies for the late reply.

Thanks Antany. I tried what you mentioned and its working. But the only thing is that which user name and password do i enter? The PC has several user accounts do i enter any of those details or is the FTP user name and password totally different?
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Unable to connect to Windows Machine Using FTPClient...
 
Similar Threads
the max number of clients to multithread the socket server
new to sockets/networking
FTP very slow
SSH Port forwarding-FTP Access
RMI Naming.rebind() Problem