FTP Passive Commands VB

I am using a VB application that I have made to upload files using FTP. But I cannot get passive commands to work on it. Could you tell me how I could use the passive mode for FTP upload and what the commands would be?
hanseldsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

liadsCommented:
Are you using an FTP component or are you implementing the connection yourself using winsock?
The PASV command has to be sent to the server. Then, the server gives you an IP and a port number (the port number needs translation), and the client needs to open another TCP connection to this IP and port to establish the data connection.
0
hanseldsAuthor Commented:
It is my own application made using the winsock control. I want to know how to initialise the passive mode and how to send the command
0
tomvergoteCommented:
I once this component which is open source
http://www.enterprisedt.com/products/edtftpnet/overview.html

please be aware that you can either
- use the component,
- use source from it and release your library gpl,
- buy a non-gpl source license

I'd suggest you just use their component as it is, it works fine
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Mike TomlinsonMiddle School Assistant TeacherCommented:
You simply send the PASV command followed by vbCrLF:

    ControlConnection.SendData "PASV" & vbCrLf

The server should come back with a 227 repsonse similiar to the below:

    227 Entering Passive Mode (IP1, IP2, IP3, IP4, P1, P2)

The "Entering Passive Mode" message may vary from FTP server to server, or may not even be present at all.  The parenthesis may not be there either, but most servers put them there.  The FTP protocol doesn't actually specify how the 227 response message should be formatted, so you have to do some intelligent parsing.  You can either look for the left and right parenthesis, or start looking for the first digit after the three digit response.  There also may or may not be spaces after the commas seperating the values.  Once you are confident you have found all the values, you put them together like this:

    IP = IP1.IP2.IP3.IP4
    Port = (P1 * 256) + P2

Then, you initiate a connection on a new winsock control to the IP and Port you just received.

~IM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonMiddle School Assistant TeacherCommented:
Once you have established your new data connection to the specifed IP and Port, send a RETR command on the control connection and the file will start streaming across your new data connection.

~IM
0
tomvergoteCommented:
Idle_Mind deserves'em imo
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.