How can I program a Linux server with client a website in gcc C/C++?
I want to program a linux server in C/C++ that will have as client a website (in Java,PhP,etc. the easiest one)
I want to be able to receive string queries from the client-website and reply it back arrays
(Do they have to be converted to HTML arrays or something?)
What do I have to do?
esgol, your jargonology is completely mixed up. 'as client a website' is completely meaningless. A website is a HTTP server (web server), along with the collection of HTML pages, images, and scripts that are served and launched by the HTTP server. Nothing about a web site is client-like. Given that, your statement 'I want to be able to receive string queries from the client-website' is equally meaningless. A web client is generally a browser, or some browser-like software.
So, I will assume that what you really mean is that you want to create a website, and that the website must provide a way of receiving information from web clients (browsers). If so, then you will need to learn about CGI, as applied to web servers. In summary, it is a method which provides for server-side extensions to be called from the web-server (so, running on the web server host), and which are given data that is passed from the web client/browser. Usually, but not necessarily, the data passed to the CGI process will originate from an HTML form that a browser loads from the server. You may also want to use PHP, which has some similarilty to CGI processes.
There are many details about how a CGI process is created, and there are many many online tutorials and examples to study. If this does not sound like what you are trying to achieve, please rephrase your question, perhaps leaving out any technical terms that you may be using incorrectly and thereby creating confusion.
Are you saying that you want a web service that returns json?
EDITL Please allow me to post it in a new topic since the title was rubish.
Ahh as i see in a C++ Web Programming Tutorial at tutorialpoints
its different in programming a web server than a simple server (is he called network server?)
The webserver uses CGI libraries
I have created a C/C++ console aplication with gcc (g++) (4.4.5) which is a simple DBMS ( Database Management System )
It takes SQL strings, parses-analyses them, and extracts the data from the DataBase (Random Access Files ) through Functions handling Data Structures, returning the reply as a char Array
The entire thing is set in the Client-Server model with 2 different classes (CLIENT-SYSTEM) communicating only through a structure called socket, though the functions 'send-listen socket'
I want now to create a real server client and was wondering how could I make instead of a simple server a webserver like you sed its called.
So I want to create a website (Php or Java) and the queries-strings that the user sents from my Website, to arrive at my api-DBMS-server -instead of going to MySQL or whatever its used- and my api-DBMS to reply back to the website the Answer table.
So whatdo I have to do? I know only about simple echo servers with UNIX berkley sockets.
Is this about JDBC-ODBC driver programming?
So its a communication between 2 web servers (the DBMS one, and the website) not a server and a client eh..
Sorry I dont have knowledge how exactly the dynamic wesites share information with their webservers :SSS
To understand, when you sed CGI the 1st i came up are the CGI effects used movies :SS
CGI = Common Gateway Interface. A HTTP server, such as Apache, runs on a host serving requests from clients (browsers). When the request URL from a browser includes cgi-bin/someProgramThatYouCreate, then the Apache web server will launch your application. Depending on the nature of the HTTP request, your application will receive data that originated on the browser as either commandline data, or as standard input (on Linux). The CGI application that you write will process the data according the the application requirements. It must also, then, compose a valid HTML page, and write it to its standard output, where the Apache web server will pass it along, back to the HTTP browser.
You can, therefore, write your application in any programming language that can read standard input, write standard output, and receive commandline arguments.
PHP applications are done differently. PHP gets built into the web server in a way that allows it to be launched from any URL, and it processes data embedded into pages resident on the server, as well as receiving data from browser clients.
In order for you to start creating a web application, you will need a host capable of running a web server. Most Linux distros include Apache as the default, and it it often set up to run with little or no configuration required. From there, you can start to compose your CGI scripts &/or PHP applications. Use a conventional browser to test, and if you use anything that is not dead-standard HTML, you will probably need to tweak it to work properly on all browsers.
Wooe thank you very much! :D
So no need to program servers from zero with forks and sockets etc. :D :D :D wow! Seems so easy
But how can the input you say arrive my api? through int main(char arg) etc.?
As I said before: 'your application will receive data that originated on the browser as either commandline data, or as standard input (on Linux). The CGI application that you write will process the data according the the application requirements. It must also, then, compose a valid HTML page, and write it to its standard output'
HTTP GET requests use the commandline to send arguments (normally key/value pairs) to the CGI application, while HTTP POST reqests use standard input for data passing.
Ahh yes I know GET POST from PhP. In order to receive from Post my c++ cgi shall have some special argument at int main() like when receiving at startup fro teh command line? How is it done
About sending from teh command line, what re you talking about there is no comand line in a browser.
About the html export, yes of course, like php and java. Browser wants HTML in the end
thank you the most for your help u already giave me :D
edit: I found some tutorials, like these. Thank they ll help. If i ll need anything else will come back
Thank you very much :D
|All times are GMT -5. The time now is 05:59 AM.|