Hi there!

i was looking at the cgi posts in the forum got inspired to use these in website's. I was wondering how to implement cgi support on a self programmed webserver? The possibilities that i think to do is to create a process of the requested cgi executable and somehow (maybe in debug mode??at the webserver :confused: ) to undercept the cgi standard input and output calls normally used in cgi-programming. These calls put in to memory susequently and send itt to the client.

My question is, before i give it a try to implement, is this above strategy right or wrong?? How does apache or IIS handles this??
Posted on 2002-08-06 04:06:42 by eisodur
Originally posted by eisodur
i was looking at the cgi posts in the forum got inspired to use these in website's. I was wondering how to implement cgi support on a self programmed webserver?

It's not too hard :). At first, you code your webserver. Simplest one will be about 5k :). After, you should correctly parse request and if it is to one of you cgi apps, you should execute it and intercept it standart output. Also, you should set some evironment variables. Output you will send to user.


The possibilities that i think to do is to create a process of the requested cgi executable and somehow (maybe in debug mode??at the webserver :confused: ) to undercept the cgi standard input and output calls normally used in cgi-programming. These calls put in to memory susequently and send itt to the client.

You must intercept standart output (f.e. to console).
Posted on 2002-08-06 05:32:46 by Aquila
Aquila,

intercept u mean like hooking/debugging the cgi or something??
Posted on 2002-08-06 05:46:48 by eisodur

Aquila,

intercept u mean like hooking/debugging the cgi or something??


What you mean by debugging cgi? How you can debug CGI? :)
Posted on 2002-08-06 06:19:22 by Aquila
i mean to createprocess of the cgi executable with the debugging option set.:)
Posted on 2002-08-06 06:23:38 by eisodur

i mean to createprocess of the cgi executable with the debugging option set.:)


Why? It's no use :). For implementing CGI you need intercept standart output (usually to console) of cgi app. You can do it with pipes. Look Iczelion tut about pipes.
Posted on 2002-08-06 06:33:53 by Aquila
thanks i'm going to read it.....again.......:tongue: never made use of those btw
Posted on 2002-08-06 07:35:29 by eisodur
The way to do this is using pipes. Create a pipe to the cgi app's standard input and one to it's output and standard error. iczellion has a tutorial on pipes
Posted on 2002-08-06 13:09:24 by Kudos