4

I am developing a project for the end of my studies. This project is basically acting as a server, is cross-platform and developed in C++.

I was wondering if it was possible to make a web interface that could be used like for instance the listener design pattern to log what the program does. This would be cross platform, and is ideal since the program is supposed to run on a distant server.

My question is: is there any web technology to could let me update my web page live when the program logs something. I know this is something unusual and I'm not an expert in web technos, that's why I am asking.

Would Erlang do it ?

Thanks for your help

EDIT: To give a more concrete example, I would like to be able to follow the execution of my program live and see the logs of my program appear on the page. The idea would be to use a web page like I would use WPF on Windows or GTK on Linux for instance. Like someone said, it would be some kind on monitor for my application.

Charles
  • 50,943
  • 13
  • 104
  • 142
Rippalka
  • 380
  • 6
  • 16

2 Answers2

7

It's much easier than you might think. A web server basically gets a request as a path name, and returns a page. If you set it up correctly, it will invoke a program to create the content. This is called "CGI".

If you can do it without live updating, it's then super-easy: just refresh the page and your program can be called again.

If you want live updating, you'll need to do a little more. The easiest way is with a little lightweight javascript. The magic word here is AJAX. There are a number of tutorials on line for both of these, just google.

The main thing is to start with a very very simple example and add to it. Javascript in particular is a little peculiar; follow the tutorials, though, and you'll get it.

Charlie Martin
  • 110,348
  • 25
  • 193
  • 263
  • 1
    Thanks a lot for your answer! I am a bit familiar with AJAX, JS and JQuery. The tricky part there is to basically update the content displayed to the user when the program processes something without having the user refresh the page. Is it even possible ? Again, thanks for your help – Rippalka Sep 28 '12 at 22:47
  • 1
    You bet. Write a function that calls your AJAX routine using `$.get()`. Put that function in a call to setInterval(fn,inerval) where fn is your function and interval is a number of milisecond, eg, 1000 for once per second. Update your display using the results. – Charlie Martin Sep 28 '12 at 23:25
  • Here's a small tut on the ajax part: http://viralpatel.net/blogs/jquery-ajax-tutorial-example-ajax-jquery-development/ – Charlie Martin Sep 28 '12 at 23:26
  • Here's an SO example of polling with setInterval(): http://stackoverflow.com/questions/6835835/jquery-simple-polling-example – Charlie Martin Sep 28 '12 at 23:27
  • 1
    Wow, I didn't know I could do that with AJAX. I am pleasantly surprised and will totally use it. This is exactly what I wanted. Sorry for my ignorance and thank you very much for that good help! – Rippalka Sep 28 '12 at 23:33
  • 1
    @CharlieMartin: except Jon Skeet, of course, because the answers learn from him ;) – Steven A. Lowe Oct 01 '12 at 03:42
0

You can embed a web server such as http://code.google.com/p/mongoose and poll it using xhr or better use websockets.

Or use a monitoring solution such as Nagios (Nagios Core is free).

Wolfgang Kuehn
  • 12,206
  • 2
  • 33
  • 46