[FASTCGI] A new newbie -> use a pure socket for communictaion
M. Frey
m.frey at avelon-cetex.com
Wed Sep 9 03:13:21 EDT 2009
Hi Jay
Thanks for your answer. And Yes, I'm working on Linux. So any Windows
limitations don't affect.
Let me state more precisely: In the code fragment I wrote the wrong
socket path. Of course the socket path is similar to the one specified
in lighttpd.conf -> /var/run/lighttpd/fastcgitest.socket
It still doesn't work. And lighttpd returns "connect failed: Permission
denied"
Am I completely wrong trying to realize a socket connection using
"fcgi_stdio.h"? Or do I have to use the "fcgio.h" header to achieve this?
Thanks for any suggestions.
Maurus
Jay Sprenkle schrieb:
> A socket is the method of communications. A port is the part of that.
> It's the 'number' assigned to a tcp connection implemented using sockets.
>
> The method defined in the fast cgiwhite paper to use tcp connections
> using passed file handles as sockets for communications will not work
> with newer versions of windows. You're not on windows are you?
>
>
> On Tue, Sep 8, 2009 at 3:46 PM, Maurus Frey <m.frey at avelon-cetex.com
> <mailto:m.frey at avelon-cetex.com>> wrote:
>
> Hi,
>
> I try to connect a C++ application on a embedded device to the web
> through fastcgi.
>
> For the first test I reused the code by E. Bareev already published on
> this list during August. (Thanks)
>
> Instead of using a port, I want to use a unix Socket.
> ...........code............
> #include <string>
> #include "fcgi_stdio.h"
> #include <stdlib.h>
> #include <iostream>
>
> void handle(FCGX_Request request){
> FCGX_FPrintF(request.out,
> "Content-type:text/html\r\n\r\n<TITLE>fastcgi</TITLE>\n<H1>Fastcgi:
> Hello world!</H1>\n");
> }
>
> int main(int argc, char* const argv[] )
> {
> std::string port = "/var/run/fastcgitest.socket";
> int listenQueueBacklog = 400;
> FCGX_Stream *in, *out, *err;
> FCGX_ParamArray envp;
>
> if(FCGX_Init()) exit(1);
>
> int listen_socket = FCGX_OpenSocket(port.c_str(),
> listenQueueBacklog);
> if(listen_socket < 0) exit(1);
>
> FCGX_Request request;
> if(FCGX_InitRequest(&request, listen_socket, 0)) exit(1);
>
> int reqCounter = 0;
> while(FCGX_Accept_r(&request) == 0)
> {
> handle(request);
> reqCounter++;
> FCGX_FPrintF(request.out, "\n\r\n\r counter: %d", reqCounter);
> FCGX_Finish_r(&request);
> }
> return 0;
> }
> ...........code............
>
> I got a 500 internal Server Error. Since this is my first fastcgi
> project using a socket, I don't really know the problem.
>
> The lighttpd.error log says:
> 2009-09-08 22:34:45: (mod_fastcgi.c.1761) connect failed: Permission
> denied on unix:/var/run/lighttpd/fastcgitest.socket
> 2009-09-08 22:34:45: (mod_fastcgi.c.2930) backend died; we'll disable it
> for 5 seconds and send the request to another backend instead:
> reconnects: 0 load: 1
> 2009-09-08 22:34:51: (mod_fastcgi.c.2743) fcgi-server re-enabled:
> unix:/var/run/lighttpd/fastcgitest.socket
>
> The lighttpd.conf looks like this:
> fastcgi.debug = 1
> fastcgi.server = (
> "/test.fcgi" =>
> ((
> "socket" => "/var/run/lighttpd/fastcgitest.socket",
> "check-local" => "disable"
> ))
> )
>
> If I start the fcgi-app the socket file
> (/var/run/lighttpd/fastcgitest.socket) will be created.
> The access rights are: srwxr-xr-x 1 root root 0 2009-09-08 22:34
> fastcgitest.socket
>
> Lighttpd runs as root, it should be able to access the socket.
>
> What could be the problem?
>
> Thanks for your support.
>
> Maurus
> _______________________________________________
> FastCGI-developers mailing list
> FastCGI-developers at mailman.fastcgi.com
> <mailto:FastCGI-developers at mailman.fastcgi.com>
> http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers
>
>
>
>
> --
> Cause united breaks guitars
> http://www.youtube.com/watch?v=5YGc4zOqozo
>
More information about the FastCGI-developers
mailing list