hi, all
I am doing a project which would download files to a fixed place from a FTP server. And every file would need a new thread. How should I do? I'd never do something about this.
Nimking
Printable View
hi, all
I am doing a project which would download files to a fixed place from a FTP server. And every file would need a new thread. How should I do? I'd never do something about this.
Nimking
You can use WinInet
For each file you have to establish a new session with the FTP Server
All u have to do is to make a class which should take username, password, and file path (to be downloaded or uploaded to and from server) in it's constructor and that class should make a thread for that file and start all the remaining process as memtioned in WinInet classes
You can use MS WinInet API (search http://msdn.microsoft.com/library for more info).
Here's a short desciption on how to do it with WinINet API:
1. Open internet session with InternetOpen()
2. Connect to FTP server with InternetConnect()
3. Download a file with FtpGetFile()
4. Close both handles (1, 2) with InternetCloseHandle()
For threading, lookup these functions in the online help:
1. CreateThread
2. _beginthread
3. _beginthreadex
Hope it helps.
Hi,
You might want to take a look at http://www.geocities.com/contactgirish/ftp.html
for code related to uploading and downloading files from a
FTP server. Its not multithreaded, but that'd be easy to
implement. Take a look in the MSDN for creating and handling
threads.
Hope this helps.
If I use two threads download two files at the same time, does it make a wrong? Does I need to split the file?
It should work to download two files from separate threads. Note however that the files won't be downloaded faster using two or more threads!!!Quote:
Originally posted by Nimking
If I use two threads download two files at the same time, does it make a wrong? Does I need to split the file?