Annotation of libwww/Library/src/HTDNS.html, revision 2.19
2.1 frystyk 1: <HTML>
2: <HEAD>
2.13 frystyk 3: <!-- Changed by: Henrik Frystyk Nielsen, 2-Apr-1996 -->
2.17 frystyk 4: <TITLE>W3C Sample Code Library libwww DNS Class</TITLE>
2.1 frystyk 5: </HEAD>
6: <BODY>
2.13 frystyk 7: <H1>
8: Domain Name Service Class
9: </H1>
2.1 frystyk 10: <PRE>
11: /*
12: ** (c) COPYRIGHT MIT 1995.
13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
2.13 frystyk 16: <P>
17: The DNS Class defines generic access to the DNS system. It maintains
18: a cache of all visited hosts so that subsequent connects to the same host
19: doesn't imply a new request to the DNS every time. Multihomed hosts are treated
20: specially in that the time spend on every connect is measured and kept in
21: the cache. On the next request to the same host, the IP-address with the
22: lowest average connect time is chosen. If one IP-address fails completely,
23: e.g. <EM>connection refused</EM> then it disabled and HTDoConnect tries one
24: of the other IP-addresses to the same host.
25: <P>
26: Every entry in the cache has its own time to live (TTL) and hence the cache
27: manages its own automatic garbage collection. Currently the TTL is <B>not</B>
28: bound to the DNS records which should be changed. You can set the DNS object
29: TTL
30: <P>
31: This module is implemented by <A HREF="HTDNS.c">HTDNS.c</A>, and it is a
2.19 ! frystyk 32: part of the <A HREF="http://www.w3.org/Library/"> W3C Sample Code Library</A>.
2.1 frystyk 33: <PRE>
34: #ifndef HTDNS_H
35: #define HTDNS_H
2.13 frystyk 36:
2.1 frystyk 37: </PRE>
2.13 frystyk 38: <PRE>typedef struct _HTdns HTdns;
2.1 frystyk 39: </PRE>
2.13 frystyk 40: <H2>
41: DNS Cache Expiration Time
42: </H2>
43: <P>
2.19 ! frystyk 44: When to remove an entry in the DNS cache. We maintain our own DNS cache as
! 45: we keep track of the connect time, pick the fastet host on multi-homed hosts
! 46: etc. However we <STRONG>DO NOT HONOR DNS TTL Records</STRONG> which is the
! 47: reason for why the expiration must be faily short (the default value is 30
! 48: mins), so that it doesn't collide with the DNS mechanism for timing out DNS
! 49: records befoew swapping IP addresses around.
2.1 frystyk 50: <PRE>
51: extern void HTDNS_setTimeout (time_t timeout);
52: extern time_t HTDNS_timeout (time_t timeout);
53: </PRE>
2.13 frystyk 54: <H2>
55: Creation and Deletion Methods
56: </H2>
57: <H3>
58: Add a DNS Object
59: </H3>
60: <P>
61: Add an element to the cache of visited hosts. The <CODE>homes</CODE> variable
62: indicates the number of IP addresses found when looking up the name. A host
63: name must <B>NOT</B> contain a port number.
64: <PRE>
65: extern HTdns * HTDNS_add (HTList * list, struct hostent * element,
66: char * host, int * homes);
67: </PRE>
68: <H3>
69: Delete a DNS object
70: </H3>
71: <P>
72: This function flushes the DNS object from the cache and frees up memory
2.1 frystyk 73: <PRE>
2.9 frystyk 74: extern BOOL HTDNS_delete (const char * host);
2.1 frystyk 75: </PRE>
2.13 frystyk 76: <H3>
77: Delete ALL DNS objects
78: </H3>
79: <P>
2.19 ! frystyk 80: This function is called from <A HREF="HTLib.html"> HTLibTerminate</A>. It
! 81: can be called at any point in time if the DNS cache is going to be flushed.
2.1 frystyk 82: <PRE>
83: extern BOOL HTDNS_deleteAll (void);
84: </PRE>
2.13 frystyk 85: <H2>
86: DNS Class Methods
87: </H2>
88: <H3>
89: Recalculating the Time Weights on Multihomed Host
90: </H3>
91: <P>
92: On every connect to a multihomed host, the average connect time is updated
93: exponentially for all the entries.
94: <PRE>
2.16 frystyk 95: extern BOOL HTDNS_updateWeigths (HTdns *dns, int cur, ms_t deltatime);
2.13 frystyk 96: </PRE>
97: <H2>
98: Resolver Functions
99: </H2>
100: <P>
101: These are the functions that resolve a host name
102: <H3>
103: Get Host By Socket
104: </H3>
105: <P>
106: This function should have been called HTGetHostByAddr but for historical
107: reasons this is not the case.
2.1 frystyk 108: <PRE>
2.7 frystyk 109: extern char * HTGetHostBySock (int soc);
2.1 frystyk 110: </PRE>
2.13 frystyk 111: <H3>
112: Get Host By Name
113: </H3>
114: <P>
115: This function gets the address of the host and puts it in to the socket
116: structure. It maintains its own cache of connections so that the communication
117: to the Domain Name Server is minimized. Returns the number of homes or -1
118: if error.
2.1 frystyk 119: <PRE>
2.15 frystyk 120: extern int HTGetHostByName (HTHost * host, char *hostname, HTRequest * request);
2.1 frystyk 121: </PRE>
122: <PRE>
123: #endif
124: </PRE>
2.13 frystyk 125: <P>
126: <HR>
2.12 frystyk 127: <ADDRESS>
2.19 ! frystyk 128: @(#) $Id: HTDNS.html,v 2.18 1998/05/14 02:10:21 frystyk Exp $
2.12 frystyk 129: </ADDRESS>
2.13 frystyk 130: </BODY></HTML>
Webmaster