SCGI
Posted: Wed Mar 19, 2014 12:41 pm
Hi,
I need now a web script which accesses a database and this very often by many clients.
Up to now I used a CGI program written in PB.
But always loading the program needs to long and is inefficient.
So I looked for the well known FastCGI...
But I could not get a friend of it.
After 2 days I found SCGI: That's it
Install the module, enable it
in your apache site.conf file.
You don't need to create /scgi physically.
Than use this PB code as first test base for a SCGI server:
To test enter something like this:
http://yourserver/scgi?para=123
in your browser.
This shows you the way...
More work to be done by you
Bernd
I need now a web script which accesses a database and this very often by many clients.
Up to now I used a CGI program written in PB.
But always loading the program needs to long and is inefficient.
So I looked for the well known FastCGI...
But I could not get a friend of it.
After 2 days I found SCGI: That's it

Install the module, enable it
and add something likea2enmod mod_scgi
Code: Select all
<Location "/scgi">
SGIHandler On
</Location>
SCGIMount /scgi 127.0.0.1:4000
You don't need to create /scgi physically.
Than use this PB code as first test base for a SCGI server:
Code: Select all
InitNetwork()
Server = CreateNetworkServer(#PB_Any, 4000, #PB_Network_TCP, "127.0.0.1")
If Server
*Buffer = AllocateMemory(1024)
If *Buffer
Repeat
If NetworkServerEvent() = #PB_NetworkEvent_Data
Client = EventClient()
Size = ReceiveNetworkData(Client, *Buffer, MemorySize(*Buffer))
If Size
Answer$ = "Status: 200 OK" +#CRLF$
Answer$ + "Content-type: text/plain" + #CRLF$
Answer$ + #CRLF$
Ptr = 0
Repeat
Buffer$ = PeekS(*Buffer + Ptr, -1, #PB_UTF8)
Ptr + StringByteLength(Buffer$) + 1
Answer$ + Buffer$ + #CRLF$
Until Ptr >= Size
SendNetworkString(Client, Answer$)
CloseNetworkConnection(Client)
EndIf
Else
Delay(10)
EndIf
ForEver
EndIf
EndIf
http://yourserver/scgi?para=123
in your browser.
This shows you the way...
More work to be done by you

Bernd