I want to transfer files across the network using C or C++. What topics should I look up? How can I do this?
Asked
Active
Viewed 2,833 times
3
-
2Not that I feel confident that I'll be able to answer the question anyway, but... this question sounds lacking in detail. – Kache Mar 16 '10 at 06:18
-
Across *what* network? If possible, just create a network share and copy the files across like you would anywhere else. – Jerry Coffin Mar 16 '10 at 06:28
4 Answers
3
You should start by choosing a protocol. HTTPS and SFTP are both good choices, but there are obviously others. Once you have that straight, you can look up choices for client and server libraries.

Matthew Flaschen
- 278,309
- 50
- 514
- 539
-
FTP is insecure, and should be used only inside a firewall, or over a secure layer (e.g. http://en.wikipedia.org/wiki/FTPS) – Matthew Flaschen Mar 16 '10 at 06:25
-
the OP doesn't necessarily need to encrypt the transmitted data. – Bertrand Marron Mar 16 '10 at 07:32
-
1@tusbar: if you have secure libraries, why not use them? For completeness, there's also scp. libcurl was suggested here: http://stackoverflow.com/questions/360259/sftp-c-library/360276#360276 – stefaanv Mar 17 '10 at 10:06
3
I would recommend looking through documentation of Windows Sockets and boost asio.

Dmitry
- 6,590
- 2
- 26
- 19
2
While you could use ReadFile
to read the file's contents and then send it over a socket, Windows also provides the TransmitFile
API to enable you to read a file's data and send it over a socket with one system call.

Aaron Klotz
- 11,287
- 1
- 28
- 22
-
-
It also allows you to prepend and append data to the file contents (such as an HTTP header). This is what IIS does. – Aaron Klotz Mar 16 '10 at 19:49