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>
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>
18 <!-- Creator : groff version 1.17.2 -->
19 <!-- CreationDate: Fri May 3 16:10:41 2002 -->
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>
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 <pthr_server_main.h>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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 <rich@annexia.org></td></table>
107 <a name="LICENSE"></a>
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>
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>