-2

I am investigating if it would be practical to use HTTP to transfer files from one of our bare metal embedded systems to/from a server. The embedded system has sockets and a TCP/IP stack.

To progress this I was thinking I would like to prototype it with a bare bones C program on a PC with nothing more elaborate than use of socket functions. (Visual Studio console app).

Are there are any basic demo source codes project around that could be a good starting point to understand how HTTP file transfer works ? i.e. how to implement things like PUT and GET etc.

  • If you really need file transfer I would go for something like ftp(s) or ssh/scp, unless you are forced to use http – Marged Oct 23 '15 at 08:04
  • In your case I would use ssh or ftp, as these are much easier. – Magisch Oct 23 '15 at 08:06
  • 1
    Unlike the previous posters, I wouldn't say that SSH is easier, especially not on a "bare metal" embedded system which possibly don't have any libraries to help or maybe even not an operating system. The FTP protocol also has it quirks that makes it harder than one would expect (like using multiple ports and connections for a single file transfer). Perhaps using [Simple FTP (SFTP)](https://en.wikipedia.org/wiki/File_Transfer_Protocol#Simple_File_Transfer_Protocol) would be an option. HTTP is otherwise pretty straight-forward if you keep the header simple, and not support everything from 1.1- – Some programmer dude Oct 23 '15 at 08:11
  • 1
    Perhaps you should mention how restricted your environment, because if you only have 4 Hz and 2 kilo of RAM our answers will be different ;-) – Marged Oct 23 '15 at 08:17
  • SSH is an unrealistic option on our bare metal box. There is no library for it and there is no O/S which has it. – user3314691 Oct 23 '15 at 11:23
  • FTP is already implemented in our system. Our connection to the server is via 3G on a moving vehicle. So connection can often be lost or interrupted. In the comparisons I saw between FTP and HTTP I saw that the suggestion that HTTP could work better in this environment. “From my anecdotal evidence, HTTP is easier to make work with dropped/slow/flaky connections; e.g. it is not needed to (re)establish a login session before (re)initiating transfer.” http://stackoverflow.com/questions/717200/comparing-http-and-ftp-for-transferring-files – user3314691 Oct 23 '15 at 11:26

2 Answers2

1

If you want the embedded system to initiate the transfers, you want it to be an HTTP/FTP client. Then use an HTTP/FTP client library like libcurl (or perhaps some other HTTP client library)

If you want the embedded system to server transfers from/to remote clients, you want it to be an HTTP server. Then use an HTTP server library like libonion (or perhaps some other HTTP server library).

You definitely need to be more familiar with HTTP and/or FTP protocols.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
0

I say, there is really no difference if it is FTP or HTTP 1.{1|0}. Having implemented both in my life. In my experience, I've implemented HTTP 1.0 servers, and HTTP 1.* clients, as well as FTP clients. An average custom-tailored implementation which is not using ANY libraries takes around a week to do. Both HTTP 1.1 and FTP support interrupted downloading, so this is not an issue as well. Both are unencrypted, so any password-protection (which is available in both) is somewhat moot.

SSH/HTTPS would be much harder because of encryption, which is a lot.

SergeyA
  • 61,605
  • 5
  • 78
  • 137