There is a simple application in C ++, I decided to write a web interface to it for practice. Enter the data in the form -> The application processes the data -> The user sees the answer in the browser. Difficulties in understanding the architecture itself.

I was thinking of listening to a specific port (80) with a socket, waiting for a request from the browser (parsing certain data), and returning a web page to it.

Is this way acceptable? And how to properly implement this task?

  • 2
    Quite right, but you can still take something ready, such as github.com/ipkn/crow - Vladimir Gamalyan
  • I suggest a cgi generator and plugins for lighttpd: bitbucket.org/sercxjo/mod_json-dev . Your program generates JSON, javascript inserts data into HTML from it, sends a POST request at the user's request and receives a new JSON. - sercxjo

1 answer 1

In my opinion, it would be more logical for the web to use more adapted tools. For example through node.js. You could implement all the necessary functionality for the frontend, and connect to your application via socket using protobuff for data exchange. Thus, there will be a clear separation of the web and not the web. And save yourself from many routine actions.

The second option is to use the web socket server directly in c ++.

  • Probably the author has exactly the case when for a simple task to drag an ecosystem of a node (and implement interaction with C ++ code), just because it is fashionable, it does not look reasonable. For an example, look at uTorrent, weighs less than a megabyte, has a web interface. Do you think it would be a good idea to distribute and install a node with it? - Vladimir Gamalyan
  • Vladimir Gamalian; Whether it is necessary to distribute the node along with the application is your guesswork. The author outlined "decided to write a web interface for the practice". It is not clear from the context how it will be applied. Maybe he wants to make SaaS from his application? For this reason, your remark based on guesswork is just as wrong as my answer. And the second option, I indicated that you can use the web socket server, without any nodes. - AkaInq
  • @Akalnq why web sockets do you offer the second option? - Vladimir Gamalyan
  • @Vladimir Gamalian Because, in my opinion, this is the path of least resistance, and processing http natively in C ++ is to say the least gourmet. - AkaInq
  • @Akalnq tell me how are you going to handle web sockets in C ++? (since this is, according to your words, much simpler than the http protocol). - Vladimir Gamalyan