External Web Interface for a C++ Application [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I am developing a web interface for a C++ application that runs on an embedded system.
I was wondering if it was possible to make a web interface that could be used to manage (set and get values) and display data provided by the application. (Something like Nagios.)
My question is: is there any technology that allows me to "communicate" between the Web interface and the C++ application?
Keep in mind that I have to do this on an embedded system, so I can't use frameworks or other things that are too heavy.
The Web Interface has to be outside the C++ Application (I don't want to code the interface in the C++ Applicaiton).
My idea was to use HTML5 and Javascript for the Web Interface, the web server which i will use is also lightweight (nginx).
If someone could give me any pointers it would be nice. Thank you in advance.

So you need two things: a local interface your web page can use to configure the C++ app, and the web page itself.
There are a few common mechanisms for such local interfaces:
modify a config file, and send SIGHUP to make the application re-read it
advantage is that you can test (and use) it directly from a shell, independently of the web interface
also note that changes persist automatically
disadvantage is that you need some scheme for storing a "last good" config file in case the edited one is damaged
use a local streams socket and simple protocol (either a UNIX socket if supported, or a localhost:port loopback-only TCP socket)
advantage is that you don't touch (and possibly damage) the config file(s)
disadvantages are that you then need some other way of persisting changes, if you want to, and that you have to write this protocol in the first place
note that so long as the protocol is text-based and not binary, you can at least still test it with telnet or netcat, so you can still use it directly from the shell
simple protocol like set variable=value, get variable etc. shouldn't be too hard
If you really want to decouple the web and C++ applications, make sure you can query the available options, ideally giving types, valid ranges and groups for them. Then, you can avoid re-coding the web page every time you add or modify an option.
You can manage that with magic comments in a config file (make sure nothing is silently defaulted with no comment), or with a list command to the stream socket.
With a bit of effort, you can probably build your grouping, data type and validation constraints into the type system of your C++ application, so both the local interface and web app can be driven automatically.

If you drop the requirement that the web server be in a different process, there are a bunch of solutions
lightweight web servers

Related

Creating a browser front-end for TigerLogic D3 DB application

I have an interesting conundrum. I have been challenged with identifying the most suitable process in which to create a "browser front-end" to an existing multi-user application built within the TigerLogic/Pick D3 environment. My research indicates there are many ways to do this; but I am struggling to decide which method is best or where to start. I have "played" with a few technologies but a commitment to one is needed to get started.
These methods include:
Creation of a complex webservice using MVS Toolkit; and engineering a client from WSDL either from scratch or using maven/wsimport. Tests indicate there is a lot more to this process than originally though for a simply WSDL.
Development of a Java based web app that harnesses the MVSPJavaAPI - I am not a JAVA developer so this means learning a new language. Development would most likely take place in Eclipse.
Using TigerLogics FlashCONNECT - resulting in additional expenditure to clients so not preferable - and more or less ruled
out.
There is also the .NET option - but I have ruled this out on the basis of needing portability.
My question is, has anyone else out there done anything like this and could you share your experience? My first task is to build a web-app that will reliably give me the D3 TCL prompt in a browser that I can customise.
I am not sure there is a definitive answer here but would like peoples thoughts and will label the most useful as the answer.
What path you choose depends in some part on your existing skill-set and whether that fits in with your portability needs. It is very difficult to give you a concrete answer to your question becaue of not knowing in which part of the chain you need the portability.
It is however possible to develop a web-browser front-end using .NET which will run on Linux or Windows, so I don't see an issue with portability here. Your web server will have to be windows based but it shouldn't matter whether D3 is running on Linux or Windows at the server-end, or whether the client desktops are running Linux or Windows.
You could try TigerLogics MVSP .NET API but I do not know if it has the power to deliver based on your needs. I believe you may find mv.NET from Bluefinity could fulfill your needs. This is in my opinion the leading product on the MultiValue market for achieving the goals you have in mind. This will mean spending money of course. For this you will get a very powerful set of tools. Also, the cost of investing in a good tool could end up smaller than the cost in terms of time, effort and potential complications of trying to do this piecemeal without spending any extra money. I am sure Flashconnect would also do the job. You would have to weigh up the cost of the different options to find out which one is right for you both technically and financially.
Not knowing whether or not you have .NET in your skill-set, I don't know whether the .NET option would be easier for you. It is however technically possible.
I would suggest using Rocket's D3 (formerly TigerLogic D3) .NET APIs and create a Web API RESTful service that you can consume with JavaScript in any other web technology and if you need to call from a D3 subroutine (in case you would) then use the MVS Toolkit.
Requirements though are D3 9.0 or later.
I've used all of the technologies described, and many more to interface with D3. I agree with #Glenn and will add... I understand you're edging away from .NET. That's fine, you don't need it. But consider that most LAMP implementations separate the DBMS servers from the web servers. That topology introduces short delays between the tiers but decouples them in case you want to use multiple web servers or multiple databases - a common topology even with D3 / MV.
I have a client where we have a Java/Grails front-end over Linux, with all data queries filtered through a single, elegant data provider class that's abstracted from application logic. That uses a web service call which I wrote in Java, calling to a .NET web service. The service is easily generated/modified, as is the client from the WSDL. From there IIS carries inbound queries to D3 via mv.NET, and at this point it doesn't matter if the D3 DBMS is in Linux or Windows. My web service could have as easily been in Linux with Java but it would then lack a pooling mechanism - see below.
If you want all Linux then you can go with the MVSP Java library. TigerLogic (now acquired by Rocket Software) committed to a PHP binding for MVSP some months ago. Rather than wait, one of my clients created a PHP wrapper around mv.NET, though MVSP is as easy. So the resulting application is essentially LAMP, but with the M = Multivalue. I have written code like this too - we can write a wrapper in any language which exposes a useful API and abstracts both connectivity method and OS dependencies. In other words it doesn't matter what languages we want to use or what OS's are involved. That part is rather trivial and subject to change later. It's better to focus on the application than the communications.
You can also go off the menu, so to speak, and create your own Java/PHP wrapper around the OS-level d3tcl command, which is a script/wrapper around the d3 executable. This allows you to open a connection yourself and pass in commands.
Whatever option you select, you need to consider that opening and closing a DBMS connection is a slow process. You do not want to script a login around every data request. You do want to open a connection and keep that open persistently, while your client code accesses and releases that persistent connection as required. This is why we like mv.NET and FlashCONNECT. With MVSP and other mechanisms you need to create your own persistence model. You'll also need to manage a pool of connection resources - what happens when you get 10 simultaneous queries, or just 1 short one after one long one? You don't want queries to back up, you don't want to reject or timeout connections, and you don't want to fire up a connection for every client. You do want the proper number of DBMS sessions waiting for inbound connections. mv.NET and FlashCONNECT do this for you, the others do not.
Personally I'd shy away from FlashCONNECT. I was there for its initial development and testing and for years of end-user implementations. It's not as widely used as the other options and is more a tool for those who aren't familiar with other options. If you're talking about Java then you're probably not inclined to use FlashCONNECT. That said, if you have developers who are not familiar with anything outside D3 then FlashCONNECT is a decent server-side tool for them while someone else is focusing on the client-side with other technologies. Everyone should use their best skillset.
Finally, (already?) if someone is not familiar with external technologies, and more intimate with D3, then other options exist like DesignBAIS and Viságe, mostly removing the burden of communications and allowing developers to work on the client-side features and back-end rules in BASIC.
I discuss all of these topics plus mobile and telephony on my blog.
HTH

Sending data securely in C++? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Can someone give me some guidance on my problem - I am writing a game (CryEngine) and I need to know how to send data - including usernames and passwords to a server where they can be stored in a database and shown on a webpage displaying the players "stats". I'd like to start with the usernames and passwords as they are the most paramount that I get right, the other stuff really doesnt have to be encrypted. Although, it might make it a bit harder for hackers to alter their stats.
So how would I approach doing this? I know my way around C++ and I have been using it for a while, I have already built a system that stores and captures the player's kills and XP etc. but this bit sounds more tricky. It sounds like I'm going to make heavy use of BOOST and possibly OpenSSL, but having never used these libraries before or having to make a secure system, I'm slightly confused. Any help or general directions are greatly appreciated!
Open SSL sounds solid, have a look here: http://www.ibm.com/developerworks/linux/library/l-openssl/index.html .
You can use almost every crypting library for this (better not writing your own stuff) but since it is client/server anyway, using a protocol/system that was designed to do exactly this, your best bet is openSSL.
The rest is a secured server with some sort of application running on it (Java EE) and handling the entries in some sort of database.
Then choose some web-language of your preference to retrieve database entries.
PS: dont do it live (eg. every headshot is an entry) but transmit the final results of a round, or once every X minutes.
I suggest using HTTPS.
Link against libcurl and with a few cookbook examples from the net you can have your client portion ready in a couple of minutes or hours. Fiddling with OpenSSL by hand could take days or weeks if you are new to it.
For the server part you can use your game's existing web server. Your game is going to have a web site, isn't it? The users will be able to access their stats via their web browsers too.
If you want to protect the score update mechanism, use regular cryptography API like crypt and a key hidden in the code to obfuscate/deobfuscate the player's score update password. It's obfuscation, not encryption, since the key ultimately resides on the client machine and can be recovered with a debugger.

Writing C++ for the Web [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Is it possible to create a C++ application that can be run trough the browser? Is there any way to link C++ application with a database (that can be used by both Mac, Linux and Windows).
It's perfectly possible to do it, back in the day (when there was no PHP around), many web applications were written in C++. There is a standard called CGI that facilitates communication between your application and your web server. This tutorial shows hot to set it up for an Apache web server, using Perl as the target language. You should be able to write a C++ program that prints out the same text and test it.
Databases can be accessed using C++ using a variety of libraries, depending on your needs and database system.
While all of this is totally possible, I'd be interested why you would do such a thing in the days of sophisticated frameworks and languages that are far more suited to web applications than C++. I'd certainly not recommend it.
CGI or FastCGI for server side C++.
NaCl for client side C++.
Database connections with things like MySql Connector.
If by "through the browser" you mean a webapp, yes - you can write CGI applications in C++, as in most other languages. See the answers to this question.
wt is a toolkit that may make it easier for you if you come from a desktop background.
About the portable database layer, take a look at these two questions. If all you need is a database that works across platforms, but don't need to be able to switch database engines across platforms, SQLite may be the way to go.
If you mean by "run through the browser" to run native code in the browser the only way I know of to execute native code in the browser is Google's NaCl.
For server side C++ no special rules apply and it's very common. All normal rules for C++ application (including databases and linking) apply here.
Any scripting langauge can run COM. You can create COM objects in C++ that you can invoke serverside from php.
Is it possible to create a C++ application that can be run trough the browser?
I'm not sure what you mean by "run through the browser" (or, for that matter, "C++ application"). pmr has already mentioned Google NaCl as one option. If "C++ application" includes C++ plugins, then "sure, you can." You can compile C++ to Javascript. If you're talking about web sites or web services, I can say "yes, it's possible; I maintain a web service that uses C++ for the backend, and Amazon was once written in C++, do you have any particular question?"
It's possible to write a lot of things in a Turing complete language. That doesn't mean it's a good idea.
Is there any way to link C++ application with a database (that can be used by both Mac, Linux and Windows).
Again, I'm not sure what you mean by "link ... with a database." You certainly can interact with a database using things like ODBC, DTL, LDAP or MongoDB. You also can embed a database in your program, using things like SQLite, MySQL embedded, Firebird embedded, Berkeley DB, LevelDB, or whatever Microsoft's calling Microsoft Jet these days. Do you have a particular question?

WebChatapp with C++ I need suggestions from the start

I can't decide which way I should take so instead of trying all options I would like to get expert's or more knowlageable people's ideas since I'm a C++ newbie. (After frustration with php for years I understood C,C++ is the way to go )
Extra info: I'm only linux user for a year :)
--Here is what I want to do: Webapp that people can register and chat and be friends. Like facebookchat but no less ability than it (should be realtime all the way) (For instance: If a friend closes the browser it should be seem unavailable).
--Options I have I guess: Using boost:asio, using BSD directly, using opensource server like nginx,lighttpd with fcgi (I din't like libev, libevent.)
--Here is main questions:
1) Is Nginx+fcgi+CPP spawning a new Cpp programme for each request (Performance would be bad)
2) Would using a ready server+FCGI make it impossible or harder the chat thing i stated above.
3) Would you choose BSD, asio or tweaking a ready server for such thing?(with a short why)
(Scability for development is main concern. I mean if it requires new implementations it should be done in future)(blaa blaa must be done)
What would you do?
I think I'd step back a bit, and consider a few questions. First and foremost, it's not apparent from your question whether you're basically trying to set up a web site (or something on that order) that provides this service, or you want to write software that (or example) others could incorporate into their web sites.
Second, it's not entirely clear whether you're interested primarily in the client side, the server side, or both. Most of what you talk about is on the server side, but the features you talk about providing are mostly on the client side.
Third, is the question of whether you're willing to write a closed system that requires your client to work with your server, or you want to use something like XMPP to provide compatibility with existing software.
To summarize: you seem to be jumping directly into nitty-gritty details of how to do things; before you can figure out how very well, you first have to decide exactly what you're going to do. Until those are answered, many of the "how" questions can't be -- and after they're answered, many of the "how" questions may easily disappear.
I would start playing with Wt (http://www.webtoolkit.eu/wt) which is a framework for Web applications, or Qt (http://qt.nokia.com/products/) which offer good http and https support

What is the best way to develop a C++ web application? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
What could be the best way of developing a C++ web application? The web app would be run on Apache HTTP server. How can you overcome challenges like sessions, persistence, context switching, multithreading etc with C++? How could one utilize C++ in best possible way to make it work like Servlets?
Take a look at Wt.
Wt (pronounced 'witty') is a C++
library and application server for
developing and deploying web
applications. It is not a 'framework',
which enforces a way of programming,
but a library.
The API is widget-centric, and
inspired by existing C++ Graphical
User Interface (GUI) APIs. To the
developer, it offers complete
abstraction of any web-specific
implementation details, including
event handling and graphics support.
It's not free for commercial use though.
Use C++ web framework like CppCMS if you like web-like
development, it is oriented for high performance and works with .
It provides:
FastCGI, SCGI and CGI interfaces.
Form processing and validation
HTML Templates system
Session management
Cache system
Transparent scale up to numerous servers.
You may give a try to Wt but it is much more
like writing GUI using browser rather then traditional web development tool.
I'm saying this as a C++ developer...
I would probably consider using Java instead. Since Java is much more commonly used for this, you'll find way more existing libraries to leverage. If you ever want to hire more people, you'll have an easier time finding web-app Java developers than web-app C++ developers.
If you insist using C++, check out:
http://rudeserver.com/
You can use Qt framework, Boost & Poco libraries to do web development in C++. Qt & Poco have DB support for various RDBMS. You may look into Axis C++ if you need to develop web services in C++. ClearSilver has C library to handle CGI and you can use C++ on top of it. Plenty of choices for you!
How can you overcome challenges like sessions, persistence, context switching, multithreading etc with C++?
The answer is what you'd expect it to be: pick libraries that handle issues when possible (multithreading) and implement libraries where necessary (generating a session key and storing it somewhere like a database).
Take a look at the Snorkel Embedded Web Server SDK. Its easy to use and produces the fastest web application solutions. http://sites.google.com/site/snorkelembedded
Try experimenting with the ffead-cpp framework, check out the home page for more information...