[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

FTP Passive Commands VB

Posted on 2004-11-22
9
Medium Priority
?
624 Views
Last Modified: 2013-11-13
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?
0
Comment
Question by:hanselds
6 Comments
 
LVL 1

Expert Comment

by:liads
ID: 12652301
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
 

Author Comment

by:hanselds
ID: 12652401
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
 
LVL 8

Expert Comment

by:tomvergote
ID: 12654965
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 80 total points
ID: 12654997
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12655049
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
 
LVL 8

Expert Comment

by:tomvergote
ID: 12828908
Idle_Mind deserves'em imo
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses
Course of the Month20 days, 13 hours left to enroll

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question