1

I am currently designing a GUI for a piece of hardware. We want the GUI to be able to be accessed over a browser. The browser would be displaying a map generated from C++ code, but I also need to send some params to the code that generates the map from buttons on the JS front end? Is there anyway to accomplish this. I have done a little research so far and know about web sockets and AJAX, but I am not entirely sure it is what I am looking for. In an ideal world I would be able to just send UDP packets, but my research tells me that is not possible, not is TCP. Is this correct?

Thank's in advance for any help!

cheesemas46
  • 139
  • 12
  • 1
    The simplest thing from a browser is to initiate an HTTP request via XMLHttpRequest – Pointy May 07 '19 at 23:26
  • Related: https://stackoverflow.com/questions/12407778/connecting-to-tcp-socket-from-browser-using-javascript –  May 08 '19 at 00:22
  • Also related: https://stackoverflow.com/questions/662328/what-is-a-simple-c-or-c-tcp-server-and-client-example –  May 08 '19 at 00:23

1 Answers1

1

Your C++ code could setup a server that listens for requests. You could use libhttpserver, for example. Then, in your JavaScript code, you can use XMLHttpRequest or the Fetch API (for newer browsers) to make an HTTP request to the server, which would then return a new static page (with the generated map embedded into the page).

uanirudhx
  • 196
  • 1
  • 6