• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

Programming FTP Client

I'm writing a windows service to scan my client FTP's site.  So far, if the client site is running on UNIX, things are working find.  I have a problem connecting to the site that running on Windows NT or WS_FTP server.   I received the following message when I try to connect to those servers.

    "No connection could be made because the target machine actively refused it".

Anybody has any idea ?  Please help.

Thanks,

Chai

   
0
chainavawongse
Asked:
chainavawongse
1 Solution
 
pbowensCommented:
Try setting your connection types to Passive. It could be a firewall issue depending on the network or machine you are connecting to. Some firewalls do not allow active FTP connections. Most servers will support this mode (PASV) and it can be set during connection.
0
 
jatinderalaghCommented:
check the ports you are trying to connect by default it is 21 but can be changed.
0
 
chainavawongseAuthor Commented:
Thank you for the responses.  I did set the mode to passive (PASV) and port 21 to connect to these servers.  

The weird thing is that I am sometime able to connect to these servers when I step through the code.  

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jatinderalaghCommented:
Then check the connection limit on the server and make sure that you close FTP connection.
0
 
jatinderalaghCommented:
for closing connection do some thing like this.

        if( clientSocket != null )
       {
         sendCommand("QUIT");
       }
 
0
 
chainavawongseAuthor Commented:
Thanks again jatinderalagh.  

How do I check the connection limit on the server?  I did send the QUIT command before I exit out of the class or before I throw out an exception.
0
 
chainavawongseAuthor Commented:
OK - I think I found the problem.

On the server that refused my connection,  when I call "PASS", it returns 230.  Then I call "SYST".  The return code was 230 still!  I was expecting the 215 reply code.  So, at this point, my program tries to throw an exception.  I call the "QUIT" command before i throw each exception and guess what's the reply code was, it was 215!

So, I'm in puzzle here.  It seems like the server is somehow 'delay' to return it actual reply code in corresponding to the command i supply.

Any networking guru out there have any idea how to work this out?  Please help.

0
 
chainavawongseAuthor Commented:
Well guys, i figured it out.  It was a multiple-line reply message from the server.  I wasn't aware of this so I stop retrieving the message before it actually ends.  Thanks for all the help though.

0
 
NetminderCommented:
Closed, 500 points refunded.
Netminder
Site Admin
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now