2

I would like to let my C++ program get some data from an HTML page. Is it possible to use HTML5 local storage for this purpose? Is there an accessible file generated by the browser?

If this is not feasible in this way, are there any other options?

For now the browser and my executable run on the same computer, and I would prefer to only use the fstream C++ library.

Pietro
  • 12,086
  • 26
  • 100
  • 193
  • 1
    cant javascript store and update files? You could have a process read from the same file, or? http://stackoverflow.com/questions/13405129/javascript-create-and-save-file maybe the answer a bit down is what your looking for – Charlie Sep 14 '16 at 17:09
  • 1
    You could use WebSockets to have an HTML5 page communicate with your C++ app. The HTML can use local scripting to read/write the browser's local storage as needed. Your app would have to implement a WebSocket server for the HTML to connect to, but WebSockets are bidirectional, so the app can send commands to the HTML. – Remy Lebeau Sep 14 '16 at 17:53
  • 2
    There's always [CGI](https://en.m.wikipedia.org/wiki/Common_Gateway_Interface) ... – Jesper Juhl Sep 14 '16 at 18:23

1 Answers1

3

The most appropriate communication channel would probably be FCGI (http://www.mit.edu/~yandros/doc/specs/fcgi-spec.html). You would need to set up a local HTTP server and configure it to process specific HTTP requests using your FCGI-compliant C++ application. Modifying your C++ application to support the FCGI protocol may be non-trivial, but the protocol itself is simple.

Here is a useful article detailing how to get started: http://chriswu.me/blog/writing-hello-world-in-fcgi-with-c-plus-plus/

linguamachina
  • 5,785
  • 1
  • 22
  • 22