I am developing my first C/C++ fastCGI app, using the FastCGI Developers Kit.
I have successfully built one of the sample programs (snippet shown below):
int main (void)
{
    int count = 0;
    long pid = getpid();
    streambuf * cin_streambuf  = cin.rdbuf();
    streambuf * cout_streambuf = cout.rdbuf();
    streambuf * cerr_streambuf = cerr.rdbuf();
    FCGX_Request request;
    FCGX_Init();
    FCGX_InitRequest(&request, 0, 0);
    while (FCGX_Accept_r(&request) == 0)
    {
       /* Handle request */
    }
    return 0;
}
However, when I run the example above, it simply terminates. Upon debugging, I realized that FCGX_Accept_r was returning an error code. Upon further investigation, I realized that the accept() method call was failing.
The actual line that fails is:
 socket = accept(listen_sock, (struct sockaddr *)&sa, &len);
The arguments passed to the function are:
listen_sock: 0
len: 112
sa:
{un = {sun_family = 0, sun_path = "\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\020\\"'\\000\\000\\032\\356m\\000\\000\\000\\000\\377\\377\\377\\377\\364\\277\\022\\000\\310\\366\\377\\277\\001\\000\\000\\000\\000\\000\\000\\000X\\366\\377\\277\\343\\276\\004\\b\\377\\377\\377\\377\\001\\000\\000\\000\\001\\000\\000\\000\\000\\000\\000\\000\\001\\000\\000\\000\\310\\366\\377\\277\\210\\366\\377\\277F\\277\\004\\b\\310\\366\\377\\277\\001\\000\\000\\000\\000"}, in = {sin_family = 0, sin_port = 0, sin_addr = {s_addr = 0}, sin_zero = "\\000\\000\\000\\000\\000\\000\\000"}}
I am new to socket programming, so I am need some assistance in being able to diagnose what is causing accept() to fail.
Given the information above, can anyone see why the call to accept() would fail?
I am developing on Ubuntu 10.x