Add to git.
[pthrlib.git] / doc / pthr_server_main.3.html
1 <html>
2 <head>
3 <meta name="generator" content="groff -Thtml, see www.gnu.org">
4 <meta name="Content-Style" content="text/css">
5 <title>pthr_server_main</title>
6 </head>
7 <body>
8
9 <h1 align=center>pthr_server_main</h1>
10 <a href="#NAME">NAME</a><br>
11 <a href="#SYNOPSIS">SYNOPSIS</a><br>
12 <a href="#DESCRIPTION">DESCRIPTION</a><br>
13 <a href="#AUTHOR">AUTHOR</a><br>
14 <a href="#LICENSE">LICENSE</a><br>
15 <a href="#VERSION">VERSION</a><br>
16
17 <hr>
18 <!-- Creator     : groff version 1.17.2 -->
19 <!-- CreationDate: Fri May  3 16:10:41 2002 -->
20 <a name="NAME"></a>
21 <h2>NAME</h2>
22 <table width="100%" border=0 rules="none" frame="void"
23        cols="2" cellspacing="0" cellpadding="0">
24 <tr valign="top" align="left">
25 <td width="10%"></td><td width="90%">
26 pthr_server_main - server framework</td></table>
27 <a name="SYNOPSIS"></a>
28 <h2>SYNOPSIS</h2>
29
30 <table width="100%" border=0 rules="none" frame="void"
31        cols="2" cellspacing="0" cellpadding="0">
32 <tr valign="top" align="left">
33 <td width="10%"></td><td width="90%">
34 <pre><b>#include &lt;pthr_server_main.h&gt;
35
36 void pthr_server_main (const char *name, void (*processor_fn) (int sock, struct sockaddr_in addr), void (*global_fn) (void), int port, int fork_into_background, int close_io, int chdir_root) __attribute__((noreturn));
37 </b></pre></td></table>
38 <a name="DESCRIPTION"></a>
39 <h2>DESCRIPTION</h2>
40
41 <table width="100%" border=0 rules="none" frame="void"
42        cols="2" cellspacing="0" cellpadding="0">
43 <tr valign="top" align="left">
44 <td width="10%"></td><td width="90%">
45 <b>pthr_server_main</b> is a convenient framework function
46 for writing servers quickly using pthrlib. It creates a
47 listener thread which listens on the given port number and
48 throws off new processor threads to handle each incoming
49 connection.</td></table>
50
51 <table width="100%" border=0 rules="none" frame="void"
52        cols="2" cellspacing="0" cellpadding="0">
53 <tr valign="top" align="left">
54 <td width="10%"></td><td width="90%">
55 <b>name</b> is the name of the server.</td></table>
56
57 <table width="100%" border=0 rules="none" frame="void"
58        cols="2" cellspacing="0" cellpadding="0">
59 <tr valign="top" align="left">
60 <td width="10%"></td><td width="90%">
61 <b>processor_fn</b> is a function which should create a new
62 processor thread for each incoming connection.</td></table>
63
64 <table width="100%" border=0 rules="none" frame="void"
65        cols="2" cellspacing="0" cellpadding="0">
66 <tr valign="top" align="left">
67 <td width="10%"></td><td width="90%">
68 <b>global_fn</b> is called after forking, but before
69 starting to accept new connections. It should perform any
70 necessary initialization.</td></table>
71
72 <table width="100%" border=0 rules="none" frame="void"
73        cols="2" cellspacing="0" cellpadding="0">
74 <tr valign="top" align="left">
75 <td width="10%"></td><td width="90%">
76 <b>port</b> is the port number to listen on.</td></table>
77
78 <table width="100%" border=0 rules="none" frame="void"
79        cols="2" cellspacing="0" cellpadding="0">
80 <tr valign="top" align="left">
81 <td width="10%"></td><td width="90%">
82 <b>fork_into_background</b> should be set if the process
83 should fork into the background (this is normally desirable
84 for server processes).</td></table>
85
86 <table width="100%" border=0 rules="none" frame="void"
87        cols="2" cellspacing="0" cellpadding="0">
88 <tr valign="top" align="left">
89 <td width="10%"></td><td width="90%">
90 <b>close_io</b> should be set if the process should close
91 file descriptors 0, 1 and 2 before starting up.</td></table>
92
93 <table width="100%" border=0 rules="none" frame="void"
94        cols="2" cellspacing="0" cellpadding="0">
95 <tr valign="top" align="left">
96 <td width="10%"></td><td width="90%">
97 <b>chdir_root</b> should be set if the process should change
98 to the root directory before starting up.</td></table>
99 <a name="AUTHOR"></a>
100 <h2>AUTHOR</h2>
101
102 <table width="100%" border=0 rules="none" frame="void"
103        cols="2" cellspacing="0" cellpadding="0">
104 <tr valign="top" align="left">
105 <td width="10%"></td><td width="90%">
106 Richard Jones &lt;rich@annexia.org&gt;</td></table>
107 <a name="LICENSE"></a>
108 <h2>LICENSE</h2>
109
110 <table width="100%" border=0 rules="none" frame="void"
111        cols="2" cellspacing="0" cellpadding="0">
112 <tr valign="top" align="left">
113 <td width="10%"></td><td width="90%">
114 GNU LGPL (see http://www.gnu.org/)</td></table>
115 <a name="VERSION"></a>
116 <h2>VERSION</h2>
117
118 <table width="100%" border=0 rules="none" frame="void"
119        cols="2" cellspacing="0" cellpadding="0">
120 <tr valign="top" align="left">
121 <td width="10%"></td><td width="90%">
122 pthrlib-2.2.2</td></table>
123 <hr>
124 </body>
125 </html>