Link to home
Start Free TrialLog in
Avatar of chainavawongse
chainavawongse

asked on

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

   
Avatar of pbowens
pbowens

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.
check the ports you are trying to connect by default it is 21 but can be changed.
Avatar of chainavawongse

ASKER

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.  

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

        if( clientSocket != null )
       {
         sendCommand("QUIT");
       }
 
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.
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.

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.

ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial