/* ** (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 #include "tcp.h" #include "HTEvntrg.h"
typedef struct _HTdns HTdns;
extern void HTDNS_setTimeout (time_t timeout); extern time_t HTDNS_timeout (time_t timeout);
extern SOCKET HTDNS_socket (HTdns *dns); extern BOOL HTDNS_setSocket (HTdns *dns, SOCKET socket); extern void HTDNS_clearActive (HTdns *dns); extern int HTDNS_socketCount (void);
extern time_t HTDNS_sockTimeout (time_t timeout); extern void HTDNS_setSockTimeout (time_t timeout);
extern HTEventCallback HTDNS_closeSocket; extern void HTDNS_setSockExpires (HTdns * dns, time_t expires); extern time_t HTDNS_sockExpires (HTdns * dns);
extern char * HTDNS_serverClass (HTdns * dns); extern void HTDNS_setServerClass (HTdns * dns, char * s_class); extern int HTDNS_serverVersion (HTdns * dns); extern void HTDNS_setServerVersion (HTdns * dns, int version); typedef enum _HTTCPType { HT_TCP_PLAIN = 0x0, /* One request at a time */ HT_TCP_BATCH = 0x1, /* Use batch requests */ HT_TCP_INTERLEAVE = 0x2 /* Can we interleave requests? */ } HTTCPType; extern HTTCPType HTDNS_connection (HTdns * dns); extern void HTDNS_setConnection (HTdns * dns, HTTCPType type);
extern BOOL HTDNS_updateWeigths (HTdns *dns, int cur, time_t deltatime);
extern BOOL HTDNS_delete (CONST char * host);
extern BOOL HTDNS_deleteAll (void);
extern char * HTGetHostBySock (int soc);
extern int HTGetHostByName (struct _HTNet *net, char *host);
#endifEnd of declaration file