Annotation of libwww/Library/src/HTDNS.html, revision 2.20

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 &nbsp;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>
2.20    ! duerst     98:   IDN (Internationalized Domain Names) Functions
        !            99: </H2>
        !           100: <H3>
        !           101:   Calculate ACE (punycode) from UTF-8 encoded IDN
        !           102: </H3>
        !           103: <P>
        !           104: Converts to ACE (Ascii-compatible encoding, punycode) from an
        !           105: Internationalized Domain name. %hh-escaping in domain name is
        !           106: accepted for backwards compatibility. Returns 0 if successful.
        !           107: </P>
        !           108: <PRE>
        !           109: extern int HTACEfromUTF8 (char *hostUTF8, char *punycode, size_t punyLength);
        !           110: </PRE>
        !           111: <H2>
2.13      frystyk   112:   Resolver Functions
                    113: </H2>
                    114: <P>
                    115: These are the functions that resolve a host name
                    116: <H3>
                    117:   Get Host By Socket
                    118: </H3>
                    119: <P>
                    120: This function should have been called HTGetHostByAddr but for historical
                    121: reasons this is not the case.
2.1       frystyk   122: <PRE>
2.7       frystyk   123: extern char * HTGetHostBySock (int soc);
2.1       frystyk   124: </PRE>
2.13      frystyk   125: <H3>
                    126:   Get Host By Name
                    127: </H3>
                    128: <P>
                    129: This function gets the address of the host and puts it in to the socket
                    130: structure. It maintains its own cache of connections so that the communication
                    131: to the Domain Name Server is minimized. Returns the number of homes or -1
                    132: if error.
2.1       frystyk   133: <PRE>
2.15      frystyk   134: extern int HTGetHostByName (HTHost * host, char *hostname, HTRequest * request);
2.1       frystyk   135: </PRE>
                    136: <PRE>
                    137: #endif
                    138: </PRE>
2.13      frystyk   139: <P>
                    140:   <HR>
2.12      frystyk   141: <ADDRESS>
2.20    ! duerst    142:   @(#) $Id: HTDNS.html,v 2.19.2.1 2003/04/02 16:41:38 duerst Exp $
2.12      frystyk   143: </ADDRESS>
2.13      frystyk   144: </BODY></HTML>

Webmaster