Domain Name Service Manager
/*
** (c) COPYRIGHT MIT 1995.
** Please first read the full copyright statement in the file COPYRIGH.
*/
This module has the common code for handling DNS access. It maintains
a cache of all visited hosts so that subsequent connects to the same
host doesn't imply a new request to the DNS every time.
Multihomed hosts are treated specially in that the time spend on every
connect is measured and kept in the cache. On the next request to the
same host, the IP-address with the lowest average connect time is
chosen. If one IP-address fails completely, e.g. connection
refused then it disabled and HTDoConnect tries one of the other
IP-addresses to the same host.
If the connect fails in the case of at single-homed host then the
entry is removed from the cache and HTDoConnect tries again asking the
DNS.
This module is implemented by HTDNS.c, and it is
a part of the W3C
Reference Library.
#ifndef HTDNS_H
#define HTDNS_H
The DNS Object
The DNS object contains information obtained from the DNS system but
in addition it stores known information about the remote server, for
example the type (HTTP/1.0, HTTP/1.1, FT etc.) along with information
on how the connections can be used (if it supports persistent TCP
connections, interleaved access etc.)
typedef struct _HTdns HTdns;
Cache Timeouts
When to remove an entry in the cache. The default value is 12h.
extern void HTDNS_setTimeout (time_t timeout);
extern time_t HTDNS_timeout (time_t timeout);
Recalculating the Time-Weights on Multihomed Hosts
On every connect to a multihomed host, the average connect time is updated
exponentially for all the entries.
extern BOOL HTDNS_updateWeigths (HTdns *dns, int cur, time_t deltatime);
Delete a host element from Cache
This function deletes a single cache entry.
extern BOOL HTDNS_delete (const char * host);
Delete ALL host elements from Cache
This function is called from
HTLibTerminate. It can be called at any point in time if the DNS
cache is going to be flushed.
extern BOOL HTDNS_deleteAll (void);
Resolver Functions
These are the functions that resolve a host name
Get Host By Socket
This function should have been called HTGetHostByAddr but for
historical reasons this is not the case.
extern char * HTGetHostBySock (int soc);
Get Host By Name
This function gets the address of the host and puts it in to the
socket structure. It maintains its own cache of connections so that
the communication to the Domain Name Server is minimized. Returns the
number of homes or -1 if error.
extern int HTGetHostByName (struct _HTNet *net, char *host);
#endif
@(#) $Id: HTDNS.html,v 2.12 1996/04/12 17:46:22 frystyk Exp $