GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
KHTTP_FCGI_GETFD(3) FreeBSD Library Functions Manual KHTTP_FCGI_GETFD(3)

khttp_fcgi_getfdget the FastCGI control socket

library “libkcgi”

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>

int
khttp_fcgi_getfd(const struct kfcgi *fcgi);

Get the control socket used for handling FastCGI processes. This should be used for polling purposes in asynchronous applications. If the returned socket descriptor is manipulated in any other way, the results are undefined.

The returned descriptor is only valid after khttp_fcgi_init(3) and prior to khttp_fcgi_free(3).

The following example starts an application in FastCGI or regular CGI mode depending upon the environment.

int
main(void)
{
  struct pollfd  pfd;
  struct kreq	 req;
  struct kfcgi	*fcgi;
  enum kcgi_err	 er;
  int rc;

  er = khttp_fcgi_init(&fcgi, NULL, 0, NULL, 0, 0);
  if (er != KCGI_OK)
    errx(1, "khttp_fcgi_init: %s", kcgi_strerror(er));

  pfd.events = POLLIN;
  pfd.fd = khttp_fcgi_getfd(fcgi);

  /* Poll on other sockets here... */
  while ((rc = poll(&pfd, 1, INFTIM)) != -1) {
    er = khttp_fcgi_parse(fcgi, &req);
    if (er != KCGI_OK)
      err(1, "khttp_fcgi_parse: %s", kcgi_strerror(er));
    if (KCGI_EXIT == er) {
      khttp_free(&req);
      break;
    }
    /* Do something. */
    khttp_free(&req);
  }
  khttp_fcgi_free(fcgi);
  if (rc == -1)
    err(1, "poll");
  return 0;
}

kcgi(3)

Written by Kristaps Dzonsons <kristaps@bsd.lv>.

July 22, 2025 FreeBSD 14.3-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.