Remote Host Information
/*
** (c) COPYRIGHT MIT 1995.
** Please first read the full copyright statement in the file COPYRIGH.
*/
This object manages the information that we know about a remote host.
This can for example be what type of host it is, and what version it
is using. Notive that a host can be both a server or a client. All
information in this module can be shared regardless of whether it is
to be used in a server application or a client application.
This module is implemented by HTHost.c, and it
is a part of the W3C
Reference Library.
#ifndef HTHOST_H
#define HTHOST_H
typedef struct _HTHost HTHost;
#include "HTChannl.h"
#include "HTReq.h"
#include "HTEvntrg.h"
The Host Object
The Host object contains information about the remote host, for
example the type (HTTP/1.0, HTTP/1.1, FTP etc.) along with information
on how the connections can be used (if it supports persistent
connections, interleaved access etc.)
Create a Host Object
We keep a cache of information that we know about a remote host. This
allows us to be much more detailed in geneating requests. Search the
host info cache for a host object or create a new one and add
it. Examples of host names are
- www.w3.org
- www.foo.com:8000
extern HTHost * HTHost_new (char * host);
Remote Host Information
This is what we know about the remote host
Set the Host Class and Version
Define the host class of the host at the other end. A
class is a generic description of the protocol which is exactly like
the access method in a URL, for example "http" etc. The host
version is a finer distinction (sub-class) between various
versions of the host class, for example HTTP/0.9, HTTP/1.1 etc. The
host version is a bit flag that the protocol module can define on
its own. That way we don't have to change this module when registering
a new protocol module. The host type is a description of
whether we can keep the connection persistent or not.
extern char * HTHost_class (HTHost * host);
extern void HTHost_setClass (HTHost * host, char * s_class);
extern int HTHost_version (HTHost * host);
extern void HTHost_setVersion (HTHost * host, int version);
Persistent Channels
The HTHost object is also responsible for handline persistent connections
Register a Persistent Channel
We don't want more than MaxSockets-2 connections to be persistent in order to avoid deadlock.
extern BOOL HTHost_setChannel (HTHost * host, HTChannel * channel);
extern BOOL HTHost_clearChannel (HTHost * host);
extern HTChannel * HTHost_channel (HTHost * host);
Is this host Persistent?
Check whether we have a persistent channel or not
extern BOOL HTHost_isPersistent (HTHost * host);
Catching a Close Event
This function is registered when the socket is idle so that we get a
notification if the socket closes at the other end. At this point we
can't use the request object as it might have been freed a long time
ago.
extern int HTHost_catchClose (SOCKET soc, HTRequest * request, SockOps ops);
Timing Persistent Channels
Normally we wait for the peer process to close persistent connections
but in order not to use up our own resources, we have a timeout on our
own. The default value is 1 hour, but you can modify the value using
the following methods:
extern time_t HTHost_persistTimeout (time_t timeout);
extern void HTHost_setPersistTimeout (time_t timeout);
Each persistent connection has an absolute value of when this
connection most likely will expire. If the peer process does not
inform us, we use our own timeout.
extern void HTHost_setPersistExpires (HTHost * host, time_t expires);
extern time_t HTHost_persistExpires (HTHost * host);
#endif /* HTHOST_H */
@(#) $Id: HTHost.html,v 2.1 1996/04/12 17:47:19 frystyk Exp $