3 .\" Manual for background name resolution
5 .\" (c) 1999, 2001, 2003, 2005, 2007, 2009, 2023, 2024 Straylight/Edgeware
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of the mLib utilities library.
12 .\" mLib is free software: you can redistribute it and/or modify it under
13 .\" the terms of the GNU Library General Public License as published by
14 .\" the Free Software Foundation; either version 2 of the License, or (at
15 .\" your option) any later version.
17 .\" mLib is distributed in the hope that it will be useful, but WITHOUT
18 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 .\" License for more details.
22 .\" You should have received a copy of the GNU Library General Public
23 .\" License along with mLib. If not, write to the Free Software
24 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
30 .\"--------------------------------------------------------------------------
31 .TH bres 3mLib "1 October 1999" "Straylight/Edgeware" "mLib utilities library"
38 .\"--------------------------------------------------------------------------
40 bres \- background name resolver
42 .\"--------------------------------------------------------------------------
46 .B "#include <mLib/bres.h>"
48 .B "typedef struct { ...\& } bres_client;"
50 .ta \w'\fBvoid bres_byname('u
51 .BI "void bres_byname(bres_client *" rc ", const char *" name ,
52 .BI " void (*" func ")(struct hostent *" h ", void *" p ),
54 .ta \w'\fBvoid bres_byaddr('u
55 .BI "void bres_byaddr(res_client *" rc ", struct inaddr " addr ,
56 .BI " void (*" func ")(struct hostent *" h ", void *" p ),
58 .BI "void bres_abort(bres_client *" rc );
59 .BI "void bres_exec(const char *" file );
60 .BI "void bres_init(sel_state *" sel );
63 .\"--------------------------------------------------------------------------
68 header file declares types and functions for doing translation between
69 host names and IP addresses in the background.
71 The system must be initialized before use by a call to
73 passing it the address of an I/O multiplexor (see
76 A resolver task is stored in an object of type
78 the storage for which is allocated by the caller. The object is a
79 structure, and its contents are unspecified. The object is initialized
80 by one of the name resolution functions
84 Each function is passed the following arguments:
86 .BI "bres_client *" rc
87 Pointer to the client block to initialize and store the resolver job's
90 .BR "struct in_addr " \fIaddr "" " (" bres_byaddr )
94 .BR "const char *" \fIname "" " (" bres_byname )
95 The IP address or hostname to resolve.
97 .BI "void (*" func ")(struct hostent *" h ", void *" p )
98 A handler function to call when the resolver job is complete.
101 A pointer argument to pass to the handler function.
105 block must not be discarded until either the job is complete (i.e., the
106 handler function has been called) or
110 The handler function is passed either the address of a
112 structure describing the resolved host, or a null pointer indicating
115 structure is as returned by the standard
116 .BR gethostbyname (3)
118 .BR gethostbyaddr (3)
119 functions. This isn't the most convenient format for the results, but
120 it does have the benefit of being standard. Similarly, errors are
121 reported through the global
127 cancels a running resolver job. When it returns, the client structure
130 There are two versions of
132 The standard one uses a pool of server processes. Incoming resolver
133 jobs are passed to an available server, or a new server is started if
134 all are busy. There is a maximum number of servers, and jobs are queued
135 once this limit is reached. Old servers which have been idle for a
136 period of time are killed off. Servers are also killed if they start
137 misbehaving or their jobs are aborted.
139 By default, servers are started simply by calling
141 This can cause undesirably high memory usage in large programs. The
144 requests the resolver system to
146 a small dedicated server program to perform name lookups to reduce
147 memory consumption. The argument to
149 is the full pathname of the server program, or null to accept the
150 default set at library configuration time (which is usually correct).
152 The other implementation of
156 library to do asynchronous resolution. It can cope with many more
157 simultaneous resolver jobs, and doesn't use up external processes. If
162 function does nothing at all.
164 For security reasons, when an address is resolved, the hostname received
165 is verified by performing a forward lookup. If the forward lookup fails
166 to return the expected IP address, an error is reported.
168 .\"--------------------------------------------------------------------------
171 .BR gethostbyname (3),
172 .BR gethostbyaddr (3),
176 .\"--------------------------------------------------------------------------
179 Mark Wooding, <mdw@distorted.org.uk>
181 .\"----- That's all, folks --------------------------------------------------