ksgi

Форк
0
/
khttp_fcgi_getfd.3 
86 строк · 2.3 Кб
1
.\" Copyright (c) Kristaps Dzonsons <kristaps@bsd.lv>
2
.\"
3
.\" Permission to use, copy, modify, and distribute this software for any
4
.\" purpose with or without fee is hereby granted, provided that the above
5
.\" copyright notice and this permission notice appear in all copies.
6
.\"
7
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
.\"
15
.Dd $Mdocdate$
16
.Dt KHTTP_FCGI_GETFD 3
17
.Os
18
.Sh NAME
19
.Nm khttp_fcgi_getfd
20
.Nd get the FastCGI control socket
21
.Sh LIBRARY
22
.Lb libkcgi
23
.Sh SYNOPSIS
24
.In sys/types.h
25
.In stdarg.h
26
.In stdint.h
27
.In kcgi.h
28
.Ft int
29
.Fo khttp_fcgi_getfd
30
.Fa "const struct kfcgi *fcgi"
31
.Fc
32
.Sh DESCRIPTION
33
Get the control socket used for handling FastCGI processes.
34
This should
35
.Em only
36
be used for polling purposes in asynchronous applications.
37
If the returned socket descriptor is manipulated in any other way, the results
38
are undefined.
39
.Pp
40
The returned descriptor is only valid after
41
.Xr khttp_fcgi_init 3
42
and prior to
43
.Xr khttp_fcgi_free 3 .
44
.Sh EXAMPLES
45
The following example starts an application in FastCGI or regular CGI
46
mode depending upon the environment.
47
.Bd -literal -offset indent
48
int
49
main(void)
50
{
51
  struct pollfd  pfd;
52
  struct kreq	 req;
53
  struct kfcgi	*fcgi;
54
  enum kcgi_err	 er;
55
  int rc;
56

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

61
  pfd.events = POLLIN;
62
  pfd.fd = khttp_fcgi_getfd(fcgi);
63

64
  /* Poll on other sockets here... */
65
  while ((rc = poll(&pfd, 1, INFTIM)) != -1) {
66
    er = khttp_fcgi_parse(fcgi, &req);
67
    if (er != KCGI_OK)
68
      err(1, "khttp_fcgi_parse: %s", kcgi_strerror(er));
69
    if (KCGI_EXIT == er) {
70
      khttp_free(&req);
71
      break;
72
    }
73
    /* Do something. */
74
    khttp_free(&req);
75
  }
76
  khttp_fcgi_free(fcgi);
77
  if (rc == -1)
78
    err(1, "poll");
79
  return 0;
80
}
81
.Ed
82
.Sh SEE ALSO
83
.Xr kcgi 3
84
.Sh AUTHORS
85
Written by
86
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
87

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.