|
-
Jan 13th, 2003, 06:17 PM
#1
Thread Starter
Hyperactive Member
Linux, MySQL and server C++ apps
I am interested in making a C++ program that runs on a linux web server. This will be a simple program that makes dynamic web pages, but does not use PHP.
my host, dreamhost.com allows C++ code and I am interested in learning how to do this.
I wonder if using compiled binary code will allow the web page respond faster or use less resources.
anyone ever done this, or know someone who has?
thank you for your time and have a good day
I am so skeptical, I can hardly believe it!
PS I am not a 'hyperactive member' I am a cool, calm, and collected member 
-
Jan 14th, 2003, 12:01 PM
#2
Black Cat
It's called CGI - your app writes the HTTP headers then HTML content to standard output and the web server sends it to the browser.
Compiled code can be fast, but the cost of creating an additional process can outweight the benefit from the addtional execution speed.
Code:
#include <stdio.h>
#include <stdlib.h>
main() {
char *chRM;
char *chQS;
chRM = getenv("HTTP_USER_AGENT");
//check for NULL or we'll get at error with printf
if (chRM == NULL) {
chRM = "NONE";
}
chQS = getenv("QUERY_STRING");
if (chQS == NULL) {
chQS = "NONE";
}
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf("<head><title>CGI Test</title></head>\n");
printf("<body>\n");
printf("<p>Hello World!\n");
printf("<br><b>HTTP_USER_AGENT:</b> ");
printf(chRM);
printf("<br><b>QUERY_STRING:</b> ");
printf(chQS);
printf("</p>\n");
printf("</body>\n");
printf("</html>\n");
return 0;
}
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Jan 14th, 2003, 12:12 PM
#3
Thread Starter
Hyperactive Member
thanks a ton
I appreciate your help
I am so skeptical, I can hardly believe it!
PS I am not a 'hyperactive member' I am a cool, calm, and collected member 
-
Jan 14th, 2003, 12:13 PM
#4
Thread Starter
Hyperactive Member
is there any way to compile on windows that allows it to run on a linux box?
I want to try this while I'm in the office and I don't have linux here
I am so skeptical, I can hardly believe it!
PS I am not a 'hyperactive member' I am a cool, calm, and collected member 
-
Jan 14th, 2003, 12:18 PM
#5
Monday Morning Lunatic
badgers - with a cross-compiler. I wasn't aware there were any for Windows though.
The code you were given was actually C, but it should make no real difference.
Depending on how your server is setup, it may be faster, it may be slower. For CGI, the main overhead is in the startup, so there'd be little difference between Perl and C, *however* Perl and PHP may be integrated into the server, resulting in almost zero overheads. This would make your C the slower option. If you have something that will run for a while (like a search or suchlike), it may be more efficient.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|