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

2.17      frystyk     1: <HTML>
                      2: <HEAD>
2.27      frystyk     3: <TITLE>Generic Network Communication</TITLE>
2.32    ! frystyk     4: <!-- Changed by: Henrik Frystyk Nielsen, 24-Sep-1995 -->
2.17      frystyk     5: </HEAD>
2.2       timbl       6: <BODY>
2.17      frystyk     7: 
2.13      frystyk     8: <H1>Generic Network Communication</H1>
                      9: 
2.17      frystyk    10: <PRE>
                     11: /*
2.25      frystyk    12: **     (c) COPYRIGHT MIT 1995.
2.17      frystyk    13: **     Please first read the full copyright statement in the file COPYRIGH.
                     14: */
                     15: </PRE>
                     16: 
2.13      frystyk    17: This module has the common code for handling TCP/IP and DECnet connections
2.17      frystyk    18: etc. The main topics of functions in this module are:
2.15      frystyk    19: 
                     20: <UL>
                     21: <LI><A HREF="#ConEst">Connection establishment</A>
                     22: <LI><A HREF="#hostcache">Cache of host names</A>
2.22      frystyk    23: <LI><A HREF="#errormsg">Errno Messages</A>
2.15      frystyk    24: <LI><A HREF="#DNS">Host and mail addresses</A>
                     25: <LI><A HREF="#Signals">Signal Handling</A>
                     26: </UL>
2.17      frystyk    27: 
                     28: This module is implemented by <A HREF="HTTCP.c">HTTCP.c</A>, and it is
                     29: a part of the <A
2.29      frystyk    30: HREF="http://www.w3.org/pub/WWW/Library/">
2.26      frystyk    31: W3C Reference Library</A>.
2.13      frystyk    32: 
2.8       frystyk    33: <PRE>
                     34: #ifndef HTTCP_H
2.2       timbl      35: #define HTTCP_H
2.30      frystyk    36: #include "HTReq.h"
                     37: #include "HTNet.h"
2.8       frystyk    38: </PRE>
                     39: 
2.22      frystyk    40: <A NAME="ConEst"><H2>Connection Management</H2></A>
2.8       frystyk    41: 
2.15      frystyk    42: All connections are established through the following functions.
2.8       frystyk    43: 
2.22      frystyk    44: <H3>Active Connection Establishment</H3>
2.8       frystyk    45: 
2.15      frystyk    46: This makes an active connect to the specified host. The <A
2.30      frystyk    47: HREF="HTReq.html#HTNet">HTNet structure</A> is parsed in
2.15      frystyk    48: order to handle errors. Default port might be overwritten by any port
                     49: indication in the <A
2.29      frystyk    50: HREF="http://www.w3.org/pub/WWW/Addressing/URL/Overview.html">URL</A>
2.15      frystyk    51: specified as &lt;host&gt;:&lt;port&gt; If it is a multihomed host then
                     52: HTDoConnect measures the time to do the connection and updates the
                     53: calculated weights in the cache of visited hosts.
2.8       frystyk    54: 
                     55: <PRE>
2.31      frystyk    56: extern int HTDoConnect (HTNet * net, char * url, u_short default_port);
2.8       frystyk    57: </PRE>
                     58: 
                     59: <H3>Passive Connection Establishment</H3>
                     60: 
                     61: This function makes a non-blocking accept on a port and polls every second
2.13      frystyk    62: until MAX_ACCEPT_POLL is reached.
2.1       timbl      63: 
2.8       frystyk    64: <PRE>
2.32    ! frystyk    65: extern int HTDoAccept (HTNet * net, SOCKFD * newfd);
        !            66: </PRE>
        !            67: 
        !            68: <H3>Listen on a Socket</H3>
        !            69: 
        !            70: Listens on the specified port. 0 means that we chose it here
        !            71: 
        !            72: <PRE>
        !            73: extern int HTDoListen (HTNet * net, u_short port, SOCKFD master);
2.8       frystyk    74: </PRE>
2.1       timbl      75: 
2.22      frystyk    76: <A NAME="errormsg"><H2>System Description of Error Message</H2></A>
2.7       luotonen   77: 
2.22      frystyk    78: Return error message corresponding to errno number given. We need to
                     79: pass the error number as a parameter as we on some platforms get
                     80: different codes from sockets and local file access.
2.1       timbl      81: 
2.8       frystyk    82: <PRE>
2.23      frystyk    83: extern CONST char * HTErrnoString      PARAMS((int errnum));
                     84: extern int HTInetStatus                        PARAMS((int errnum, char * where));
2.8       frystyk    85: </PRE>
2.1       timbl      86: 
2.13      frystyk    87: <H3>Parse a Cardinal Value</H3>
                     88: 
2.8       frystyk    89: <PRE>
2.1       timbl      90: /*     Parse a cardinal value                                 parse_cardinal()
                     91: **     ----------------------
                     92: **
                     93: ** On entry:
                     94: **     *pp points to first character to be interpreted, terminated by
                     95: **     non 0..9 character.
                     96: **     *pstatus points to status already valid,
                     97: **     maxvalue gives the largest allowable value.
                     98: **
                     99: ** On exit:
                    100: **     *pp points to first unread character,
                    101: **     *pstatus points to status updated iff bad
                    102: */
2.2       timbl     103: 
2.16      frystyk   104: extern unsigned int HTCardinal PARAMS((int *           pstatus,
2.7       luotonen  105:                                       char **          pp,
                    106:                                       unsigned int     max_value));
2.8       frystyk   107: </PRE>
                    108: 
2.15      frystyk   109: <A NAME="DNS"><H2>Internet Name Server Functions</H2></A>
2.8       frystyk   110: 
                    111: The following functions are available to get information about a
                    112: specified host.
                    113: 
                    114: <H3>Produce a string for an internet address</H3>
                    115: 
                    116: This function is equivalent to the BSD system call <B>inet_ntoa</B> in that it
                    117: converts a numeric 32-bit IP-address to a dotted-notation decimal string. The
                    118: pointer returned points to static memory which must be copied if it is to be
                    119: kept.
                    120: 
                    121: <PRE>
2.16      frystyk   122: extern CONST char * HTInetString PARAMS((struct sockaddr_in * sin));
2.8       frystyk   123: </PRE>
2.1       timbl     124: 
2.12      frystyk   125: <A NAME="HTGetHostName"><H3>Get Name of This Machine</H3></A>
2.6       luotonen  126: 
2.14      frystyk   127: This function returns a CONET char pointer to a static location containing
                    128: the name of this host or NULL if not available.
2.7       luotonen  129: 
2.8       frystyk   130: <PRE>
2.32    ! frystyk   131: extern CONST char * HTGetHostName (void);
2.12      frystyk   132: </PRE>
                    133: 
                    134: 
                    135: <H3>Set Name of This Machine</H3>
                    136: 
                    137: This function overwrites any other value of current host name. This might
                    138: be set by the user to change the value in the ID value parsed to a news host
2.14      frystyk   139: when posting. The change doesn't influence the <A HREF="HTTCP.html#Mailaddress">Mail Address</A> as they are stored in two different locations. If, however,
                    140: the change is done before the first call to HTGetMailAddress() then this 
                    141: function will use the new host and domain name.
                    142: 
                    143: <PRE>
2.16      frystyk   144: extern void HTSetHostName PARAMS((char * host));
2.14      frystyk   145: </PRE>
                    146: 
2.20      frystyk   147: <H3>Cleanup Memory</H3>
                    148: 
2.30      frystyk   149: Called from <A HREF="HTReq.html#Library">HTLibTerminate</A>
2.20      frystyk   150: 
                    151: <PRE>
2.32    ! frystyk   152: extern void HTFreeHostName (void);
2.20      frystyk   153: </PRE>
2.14      frystyk   154: 
                    155: <H3>Get Domain Name of This Machine</H3>
                    156: 
                    157: This function rerturns the domain name part of the host name as returned by
                    158: HTGetHostName() function. Changing the domain name requires a call to 
                    159: HTSetHostname().
2.12      frystyk   160: 
                    161: <PRE>
2.32    ! frystyk   162: extern CONST char *HTGetDomainName (void);
2.8       frystyk   163: </PRE>
2.2       timbl     164: 
2.12      frystyk   165: 
2.13      frystyk   166: <A NAME="Mailaddress"><H3>Get User Mail Address</H3></A>
2.12      frystyk   167: 
2.13      frystyk   168: This functions returns a char pointer to a static location containing the
                    169: mail address of the current user. The static location is different from the
                    170: one of the current host name so different values can be assigned. The default
                    171: value is &lt;USER&gt;@hostname where hostname is as returned by HTGetHostName().
2.12      frystyk   172: 
                    173: <PRE>
2.32    ! frystyk   174: extern CONST char * HTGetMailAddress (void);
2.12      frystyk   175: </PRE>
                    176: 
                    177: 
                    178: <H3>Set User Mail Address</H3>
                    179: 
                    180: This function overwrites any other value of current mail address. This might
2.29      frystyk   181: be set by the user to change the value in the  <A HREF="http://www.w3.org/pub/WWW/Protocols/HTTP/HTRQ_Headers.html#from">From field</A> in the <A HREF="http://www.w3.org/pub/WWW/Protocols/HTTP/HTTP2.html">HTTP Protocol</A>.
2.12      frystyk   182: 
                    183: <PRE>
2.16      frystyk   184: extern void HTSetMailAddress PARAMS((char * address));
2.20      frystyk   185: </PRE>
                    186: 
                    187: <H3>Free Memory</H3>
                    188: 
2.30      frystyk   189: Called by <A HREF="HTReq.html#Library">HTLibTerminate</A>
2.20      frystyk   190: 
                    191: <PRE>
2.32    ! frystyk   192: extern void HTFreeMailAddress (void);
2.12      frystyk   193: </PRE>
                    194: 
2.15      frystyk   195: <H2>Signal Handling</H2>
                    196: 
                    197: This is only necessary to compile on a few platforms and only if the
2.24      frystyk   198: application does not have its own signal handling. It is required on
                    199: Solaris 2.3 (and other SVR4 platforms?) due to a bug in the TCP
                    200: kernel. When a <CODE>connect()</CODE> is tried to a illegal port,
                    201: solaris gives a SIGPIPE signal instead of returning <EM>Connection
                    202: refused</EM>.
2.12      frystyk   203: 
2.8       frystyk   204: <PRE>
2.18      frystyk   205: #ifdef WWWLIB_SIG
2.32    ! frystyk   206: extern void HTSetSignal (void);
2.15      frystyk   207: #endif
                    208: 
2.2       timbl     209: #endif   /* HTTCP_H */
2.8       frystyk   210: </PRE>
2.15      frystyk   211: 
2.8       frystyk   212: End of file
                    213: </BODY>
                    214: </HTML>
2.12      frystyk   215: 
                    216: 
                    217: 

Webmaster