tags:

views:

119

answers:

2

I am have configured a Web Server to use a 'remote' fastCGI application over a named pipe (it's actually on the same windows host). I am now trying to find out how to start the fastCGI application to use this pipe but am unsure how this should be done. Other OS's seem to have spawn-fcgi utilities for doing this but there doesn't seem to be anything similar for Windows.

This is my APP:

#include <stdio.h>
#include "fcgi_stdio.h"

int main(int argc, char ** argv)
{
  while (FCGI_Accept() >= 0) {
    printf("Content-type: text/html\r\n"
        "\r\n"
        "<title>Web Services Interface Module</title>"
        "<h1>Web Services Interface Module</h1>\n");
  }
  return(0);
}

Out of interest I am using Abyss Web Server though I hope that doesn't have a bearing on the answer.

Best Regards

A: 
 /*
 *----------------------------------------------------------------------
 *
 * FCGX_OpenSocket --
 *
 *  Create a FastCGI listen socket.
 *
 *  path is the Unix domain socket (named pipe for WinNT), or a colon
 *  followed by a port number.  e.g. "/tmp/fastcgi/mysocket", ":5000"
 *
 *  backlog is the listen queue depth used in the listen() call.
 *
 *  Returns the socket's file descriptor or -1 on error.
 *
 *----------------------------------------------------------------------
 */
 DLLAPI int FCGX_OpenSocket(const char *path, int backlog);

By default libfcgi reads from stdin. So reopen stdin handle as pipe.

 dup2(FCGX_OpenSocket("pipe name", 5),0);
ygrek
A: 

The FCGI interface does not let you do this, instead use the FCGX interface. Call FCGX_Open_Socket to listen on a specific port e.g. 9345 or a named pipe.

FCGX_OpenSocket(":9345", 500);

Then you don't need to use a utility like spawn_fcgi to start your application at all.

Howard May