Page 1 of 2
Help. about fascgi.thanks you.
Posted: Thu Jan 21, 2010 5:43 pm
by ruyi7952
my webserver baseon the Apache(Apache/2.2.14 (Win32) DAV/2 mod_fcgid/2.3.4 mod_autoindex_color PHP/5.3.1).the libfcgi it's "2.4.1 snap-2009" and compiled by VC6 SP6.
but this code can compiled and runing console,but it's do not working apache with fastcgi mode.
Code: Select all
OpenConsole()
If OpenLibrary(0, "libfcgi.dll")
*FCGI_Accept = GetFunction(0, "FCGI_Accept")
CRLF.s = Chr(13)+Chr(10)
EndIf
;-- Initalize our counter before the fcgi main loop
count.l
;
; '-- Loop until fcgi says otherwise
While CallFunctionFast(*FCGI_Accept) >= 0
count=count+1
;for http header
Print("Content-type: text/html" + CRLF)
Print(CRLF)
; http header EOF
PrintN("<html><head><title>FastCGI PBEcho</title></head><body>")
PrintN("<h1>FastCGI PureEcho</h1><br/>")
PrintN("Request Number:" + Str(count) + "<br/>")
PrintN("</html>")
Wend
CloseLibrary(0)
CloseConsole()
BTW an c code worked.
Code: Select all
//
// FastCGI 环境测试代码。
//
#include "fcgi_stdio.h"
#include <stdlib.h>
#include <string.h>
int main(void)
{
// 初始化
int num = 0;
// WEB事件
while (FCGI_Accept() >= 0) {
printf("Content-type: text/html\r\n\r\n");
printf("<html>\nCOUNT:%d\n</html>", ++num);
}
// WEB事件结束
return 0;
}
why???
please help me
thanks you.
ruyi7952
Re: Help. about fascgi.thanks you.
Posted: Thu Jan 21, 2010 6:51 pm
by ruyi7952
apache error.log
[Fri Jan 22 01:45:42 2010] [notice] Digest: generating secret for digest authentication ...
[Fri Jan 22 01:45:42 2010] [notice] Digest: done
[Fri Jan 22 01:45:43 2010] [notice] Apache/2.2.14 (Win32) DAV/2 mod_fcgid/2.3.4 mod_autoindex_color PHP/5.3.1 configured -- resuming normal operations
[Fri Jan 22 01:45:43 2010] [notice] Server built: Nov 11 2009 14:29:03
[Fri Jan 22 01:45:43 2010] [notice] Parent: Created child process 5836
[Fri Jan 22 01:45:43 2010] [notice] Digest: generating secret for digest authentication ...
[Fri Jan 22 01:45:43 2010] [notice] Digest: done
[Fri Jan 22 01:45:44 2010] [notice] Child 5836: Child process is running
[Fri Jan 22 01:45:44 2010] [notice] Child 5836: Acquired the start mutex.
[Fri Jan 22 01:45:44 2010] [notice] Child 5836: Starting 150 worker threads.
[Fri Jan 22 01:45:44 2010] [notice] Child 5836: Starting thread to listen on port 80.
[Fri Jan 22 01:46:22 2010] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Fri Jan 22 01:46:22 2010] [notice] Digest: generating secret for digest authentication ...
[Fri Jan 22 01:46:22 2010] [notice] Digest: done
why purebasic do not work??
why C worked??

Re: Help. about fascgi.thanks you.
Posted: Thu Jan 21, 2010 8:41 pm
by Rook Zimbabwe
Honestly... I mean we know you are logging this!
What port did you tell it to listen to?
Re: Help. about fascgi.thanks you.
Posted: Thu Jan 21, 2010 10:14 pm
by ruyi7952
hi Rook Zimbabwe,
thanks for your reply.
fastcgi it's double mode, stdio mode link cgi and app mode link php-cgi. app needed list a port,stdio do not need.
it's a bug for purebasic I/O function.
i have tested use printf() in gcc vc icc and d working ,but in purebasic printf() it's do not work.
i hava use FCGI_puts() function in libfcgi.dll, the purebasic codes it's working.
Re: Help. about fascgi.thanks you.
Posted: Thu Jan 21, 2010 10:27 pm
by c4s
ruyi7952 wrote:i have tested use printf() in gcc vc icc and d working ,but in purebasic printf() it's do not work.
PrintF() isn't a PureBasic command or are you talking about PrintN()?
Maybe Print("text" + #CRLF$) (or just #CR$ / #LF$) is doing what you want?
Re: Help. about fascgi.thanks you.
Posted: Thu Jan 21, 2010 11:06 pm
by ruyi7952
hi c4s
thanks for your reply.
yes,it's print().
but it's not work for fastcgi.
Code: Select all
OpenConsole()
If OpenLibrary(0, "libfcgi.dll")
*FCGI_Accept = GetFunction(0, "FCGI_Accept")
CRLF.s = Chr(13)+Chr(10)
EndIf
;-- Initalize our counter before the fcgi main loop
count.l
ASCIIZ.s = Space(10000)
;
; '-- Loop until fcgi says otherwise
While CallFunctionFast(*FCGI_Accept) >= 0
count=count+1
;for http header
Print("Content-type: text/html" + #CRLF$)
Print(#CRLF$)
; http header EOF
PrintN("<html><head><title>FastCGI PBEcho</title></head><body>")
PrintN("<h1>FastCGI PureEcho</h1><br/>")
PrintN("Request Number:" + Str(count) + "<br/>")
PrintN("</html>")
; '-- Tell fcgi we're exiting If called more than 10 times
; If count > 10
; CallFunctionFast(*FCGI_SetExitStatus, 0)
; CallFunctionFast(*FCGI_Finish)
; End
; ; EXIT DO
; EndIf
Wend
CloseLibrary(0)
CloseConsole()
Re: Help. about fascgi.thanks you.
Posted: Fri Jan 22, 2010 2:53 am
by Rook Zimbabwe
Code: Select all
Print("Content-type: text/html" + #CRLF$)
PrintN("")
; http header EOF
I would cheat and use that to go to the next line to start with.
I am looking at how this program tells the calling program whats happening... You may have to prototype to get teh proper return from the program. Do you know if the DLL was written in C++ or is a .NET component? You may have to use COMMate if that is the case...
Re: Help. about fascgi.thanks you.
Posted: Fri Jan 22, 2010 3:18 am
by ruyi7952
hi,Rook Zimbabwe.
FastCGI SDK from http://www.fastcgi.com,the libfcgi.dll compiled by vc6 sp6.
DLLAPI int FCGI_Accept(void);
Code: Select all
Print("Content-type: text/html" + #CRLF$)
PrintN("")
do not work...
ruyi7952
Re: Help. about fascgi.thanks you.
Posted: Fri Jan 22, 2010 11:48 am
by Trond
The whole point of fastcgi is that stdin/stdout is not used. You can't use PrintN().
When you use fastcgi in C, it replaces the default printf() with a special fastcgi function.
Re: Help. about fascgi.thanks you.
Posted: Fri Jan 22, 2010 11:58 am
by ruyi7952
hi Trond
thanks for your reply.
The fcgi_stdio Library: I/O Compatibility
The implementation for I/O compatibility is that the library fcgi_stdio.h contains macros to translate the types and procedures defined in stdio.h into the appropriate FastCGI calls. For example, consider a FastCGI program written in C containing the following line of code:
fprintf(stdout, "<H2>Aerobic Juggling</H2>/n");
fcgi_stdio.h
header file contains the macro
#define fprintf FCGI_fprintf
So the preprocessor translates the fprintf call into the following call:
FCGI_fprintf(stdout, "<H2>Aerobic Juggling</H2>/n");
FCGI_fprintf
takes the same arguments as fprintf.
The implementation of FCGI_fprintf tests the file to see if it is a normal C stream or a FastCGI stream, and calls the appropriate implementation.
The fcgi_stdio.h header file contains macros to translate calls to all ISO stdio.h routines (and all conventional Posix additions, such as fileno, fdopen, popen, and pclose) into their FastCGI equivalents
Re: Help. about fascgi.thanks you.
Posted: Fri Jan 22, 2010 5:09 pm
by Rook Zimbabwe
FCGI_fprintf(stdout, "<H2>Aerobic Juggling</H2>/n");
I think the " stdout " is the issue... isn't the console opened in PB a specialized window???
Re: Help. about fascgi.thanks you.
Posted: Fri Jan 22, 2010 5:43 pm
by ruyi7952

I don't know .
Re: Help. about fascgi.thanks you.
Posted: Fri Jan 22, 2010 6:34 pm
by Fred
No, it's not, it should work.
Re: Help. about fascgi.thanks you.
Posted: Fri Jan 22, 2010 9:35 pm
by ruyi7952
hi Fred,
thanks for your replay.
you say work??how working???
please. :roll:
Re: Help. about fascgi.thanks you.
Posted: Sat Jan 23, 2010 2:03 pm
by Trond
Fred wrote:No, it's not, it should work.
It should absolutely not work. It's totally impossible.
Why didn't anyone read my post?
FCGI doesn't use stdout/stdin. FCGI uses a socket.
The implementation of FCGI_fprintf tests the file to see if it is a normal C stream or a FastCGI stream, and calls the appropriate implementation.
If it is a FastCGI stream the appropriate implementation is to pack the message in a struct and send over the socket connection. Not using stdout.