Annotation of libwww/Library/src/HTTCP.html, revision 2.9

2.2       timbl       1: <HEADER>
                      2: <TITLE>/Net/dxcern/userd/timbl/hypertext/WWW/Library/src/HTTCP.html</TITLE></HEADER>
                      3: <BODY>
                      4: <H1>Generic TCP/IP Communication</H1>This module has the common code for
                      5: handling TCP/IP connections etc.
2.8       frystyk     6: <PRE>
                      7: #ifndef HTTCP_H
2.2       timbl       8: #define HTTCP_H
                      9: 
2.8       frystyk    10: #include "tcp.h"
                     11: 
2.2       timbl      12: #include "HTUtils.h"
2.8       frystyk    13: #include "HTAccess.h"
2.1       timbl      14: 
                     15: #ifdef SHORT_NAMES
                     16: #define HTInetStatus           HTInStat
                     17: #define HTInetString           HTInStri
                     18: #define HTParseInet            HTPaInet
                     19: #endif
2.8       frystyk    20: </PRE>
                     21: 
                     22: <H2>Connection Management</H2>
                     23: 
                     24: Theese functions handle access to the net.
                     25: 
                     26: <H3>Active Connection Establishment</H3>
                     27: 
                     28: This makes an active connect to the specified host. The request structure is
                     29: parsed in order to handle errors. Default port might be overwritten by any
                     30: port indication in the URL specified as &lt;host&gt;:&lt;port&gt; If it is
                     31: a multihomed host then HTDoConnect measures the time to do the connection and
                     32: updates the calculated weights in the cache of visited hosts. 
                     33: 
                     34: <PRE>
                     35: extern int HTDoConnect PARAMS((        HTRequest       *request,
                     36:                                char            *url,
                     37:                                u_short         default_port,
                     38:                                int             *sockfd,
                     39:                                u_long          *addr));
                     40: </PRE>
                     41: 
                     42: 
                     43: <H3>Passive Connection Establishment</H3>
                     44: 
                     45: This function makes a non-blocking accept on a port and polls every second
                     46: until MAX_ACCEPT_POLL or interrupted by user.
2.1       timbl      47: 
2.8       frystyk    48: <PRE>
                     49: extern int HTDoAccept PARAMS((HTRequest *request, int sockfd));
                     50: </PRE>
2.1       timbl      51: 
2.8       frystyk    52: <H2>Caching Hosts</H2>
                     53: 
                     54: This is mainly an internal matter to the HTTCP.c module but it keeps a
                     55: cache of all visited hosts so that we don't have to consult the DNS every
                     56: time. One public function is HTTCPAddrWeights(). It updates the calculated
                     57: weights on the time it takes to sestablish a connection.
                     58: 
                     59: <PRE>
                     60: extern void HTTCPAddrWeights PARAMS((char * host, time_t deltatime));
                     61: </PRE>
                     62: 
2.9     ! frystyk    63: <H3>Control Variables</H3>
        !            64: 
        !            65: This parameter determines the maximum number of hosts in the cache. If a 
        !            66: connect call fails, the entry is automaticly removed from the cache so that 
        !            67: next time we ask the DNS. 
        !            68: 
        !            69: <PRE>
        !            70: extern unsigned int    HTConCacheSize;
        !            71: </PRE>
2.8       frystyk    72: 
                     73: <H2>Errors and status indications</H2>
                     74: 
                     75: Theese functions return an explanation if an error has occured.
                     76: 
                     77: <H3>Errno Message</H3>
2.7       luotonen   78: 
2.8       frystyk    79: Return error message corresponding to current errno, just like strerror().
2.7       luotonen   80: 
2.8       frystyk    81: <PRE>
                     82: extern CONST char * HTErrnoString NOPARAMS;
                     83: </PRE>
2.1       timbl      84: 
2.8       frystyk    85: <H3>Description of what Caused the Error</H3>
2.1       timbl      86: 
2.8       frystyk    87: The parameter `where' gives a description of what caused the error, often
                     88: the name of a system call. <P>
2.7       luotonen   89: 
2.8       frystyk    90: This function should only rarely be called directly. Instead the common error
                     91: function HTErrorAdd() should be used as then the error is parsed all the way
                     92: to the user. The function returns a negative status in the unix way.
2.1       timbl      93: 
2.8       frystyk    94: <PRE>
                     95: extern int HTInetStatus PARAMS((char * where));
                     96: </PRE>
2.1       timbl      97: 
2.8       frystyk    98: <PRE>
2.1       timbl      99: /*     Parse a cardinal value                                 parse_cardinal()
                    100: **     ----------------------
                    101: **
                    102: ** On entry:
                    103: **     *pp points to first character to be interpreted, terminated by
                    104: **     non 0..9 character.
                    105: **     *pstatus points to status already valid,
                    106: **     maxvalue gives the largest allowable value.
                    107: **
                    108: ** On exit:
                    109: **     *pp points to first unread character,
                    110: **     *pstatus points to status updated iff bad
                    111: */
2.2       timbl     112: 
2.7       luotonen  113: PUBLIC unsigned int HTCardinal PARAMS((int *           pstatus,
                    114:                                       char **          pp,
                    115:                                       unsigned int     max_value));
2.8       frystyk   116: </PRE>
                    117: 
                    118: <H2>Internet Name Server Functions</H2>
                    119: 
                    120: The following functions are available to get information about a
                    121: specified host.
                    122: 
                    123: <H3>Produce a string for an internet address</H3>
                    124: 
                    125: This function is equivalent to the BSD system call <B>inet_ntoa</B> in that it
                    126: converts a numeric 32-bit IP-address to a dotted-notation decimal string. The
                    127: pointer returned points to static memory which must be copied if it is to be
                    128: kept.
                    129: 
                    130: <PRE>
                    131: extern CONST char * HTInetString PARAMS((struct sockaddr_in * sin));
                    132: </PRE>
                    133: 
                    134: <H3>Parse an internet node address and port</H3>
                    135: 
                    136: This function finds the address of a specified host and fills out the sockaddr
                    137: structure. str points to a string with a node name or number, with optional
                    138: trailing colon and port number. sin points to the binary internet or decnet
                    139: address field. <P>
                    140: 
                    141: On exit *sin is filled in. If no port is specified in str, that field is left
                    142: unchanged in *sin. If it is a multihomed host then multihomed is returned as
                    143: YES. This is used for knowing when to measure the setup time for a connection
                    144: in order to use the fastest IP-address on the multihomed host.
                    145: <PRE>
                    146: extern int HTParseInet PARAMS((struct sockaddr_in *    sin,
                    147:                               CONST char *             str,
                    148:                               BOOL *                   multihomed));
                    149: </PRE>
                    150: 
                    151: <H3>Name of a Machine on the Other Side of a Socket</H3>
2.2       timbl     152: 
2.8       frystyk   153: This function should have been called HTGetHostByAddr but for historical
                    154: reasons this is not the case.
2.1       timbl     155: 
2.8       frystyk   156: <PRE>
                    157: extern char * HTGetHostName PARAMS((int soc));
                    158: </PRE>
                    159: 
                    160: <H3>Host address retuned for specified host name</H3>
                    161: 
                    162: This function gets the address of the host and puts it in to the socket
                    163: structure. It maintains its own cache of connections so that the communication
                    164: to the Domain Name Server is minimized. If it is a multihomed host, then 
                    165: `multi' is set to YES.
                    166: 
                    167: <PRE>
                    168: extern char * HTGetHostByName PARAMS((char *host, SockA *sin, BOOL *multi));
                    169: </PRE>
2.7       luotonen  170: 
2.1       timbl     171: 
2.8       frystyk   172: <H3>Get Name of This Machine</H3>
2.6       luotonen  173: 
2.8       frystyk   174: This functions a char pointer to a static location containing the name of this
                    175: host.
2.7       luotonen  176: 
2.8       frystyk   177: <PRE>
                    178: extern CONST char * HTHostName NOPARAMS;
                    179: </PRE>
2.2       timbl     180: 
2.8       frystyk   181: <PRE>
2.2       timbl     182: #endif   /* HTTCP_H */
2.8       frystyk   183: </PRE>
                    184: End of file
                    185: </BODY>
                    186: </HTML>

Webmaster