Annotation of libwww/Library/src/HTNet.html, revision 2.21

2.1       frystyk     1: <HTML>
                      2: <HEAD>
2.17      frystyk     3: <TITLE>Asyncronous Socket Management</TITLE>
2.21    ! frystyk     4: <!-- Changed by: Henrik Frystyk Nielsen,  2-Oct-1995 -->
2.1       frystyk     5: </HEAD>
                      6: <BODY>
2.2       frystyk     7: 
2.17      frystyk     8: <H1>Asyncronous Socket Management</H1>
2.1       frystyk     9: 
2.5       frystyk    10: <PRE>
                     11: /*
2.8       frystyk    12: **     (c) COPYRIGHT MIT 1995.
2.5       frystyk    13: **     Please first read the full copyright statement in the file COPYRIGH.
                     14: */
                     15: </PRE>
                     16: 
2.1       frystyk    17: This module contains the routines for handling the set of active
2.2       frystyk    18: sockets currently in use by the multithreaded clients. It is an
                     19: internal module to the Library, the application interface is
2.15      frystyk    20: implemented in the <A HREF="HTEvntrg.html">Event Module</A>. Look for
2.2       frystyk    21: more information in the <A
2.17      frystyk    22: HREF="http://www.w3.org/pub/WWW/Library/User/Architecture/">
2.2       frystyk    23: Multithread Specifications</A>. <P>
2.1       frystyk    24: 
2.17      frystyk    25: This module is implemented by <A HREF="HTNet.c">HTNet.c</A>, and it is
                     26: a part of the <A HREF="http://www.w3.org/pub/WWW/Library/">W3C
                     27: Reference Library</A>.
2.1       frystyk    28: 
                     29: <PRE>
2.17      frystyk    30: #ifndef HTNET_H
                     31: #define HTNET_H
2.21    ! frystyk    32: #include "HTEvntrg.h"
2.17      frystyk    33: #include "HTReq.h"
2.1       frystyk    34: </PRE>
                     35: 
2.17      frystyk    36: <H2>The HTNet Object</H2>
2.1       frystyk    37: 
2.17      frystyk    38: The <CODE>HTNet</CODE> object is the core of the request queue
                     39: management. This object contains information about the socket
                     40: descriptor, the input read buffer etc. required to identify and
                     41: service a request. <P>
2.1       frystyk    42: 
                     43: <PRE>
2.18      frystyk    44: typedef struct _HTNet HTNet;
2.1       frystyk    45: </PRE>
                     46: 
2.17      frystyk    47: <H2>Request Termination Call Back Functions</H2>
                     48: 
                     49: The termination callback functions is a set of functions that can be
                     50: registered by the application to be called when a request has
                     51: terminated. There can be more than one callback function which are
                     52: called on turn and each callback function can be associated with a
                     53: status code of the request. For example one callback function can be
                     54: registered for HT_LOADED, another for HT_ERROR etc.
                     55: 
                     56: <H3>Register a Request Callback</H3>
2.2       frystyk    57: 
2.17      frystyk    58: Register a call back function that is to be called on every
                     59: termination of a request. Several call back functions can be
                     60: registered in which case all of them are called in the reverse order
                     61: of which they were registered (last one first). The status signifies
                     62: which call back function to call depending of the result of the
                     63: request. This can be
2.1       frystyk    64: 
2.17      frystyk    65: <DL>
                     66: <DT>HT_ERROR
                     67: <DD>An error occured
                     68: <DT>HT_LOADED
                     69: <DD>The document was loaded
                     70: <DT>HT_NO_DATA
                     71: <DD>OK, but no data
                     72: <DT>HT_RETRY
                     73: <DD>Retry request after at a later time
                     74: <DT>HT_ALL
                     75: <DD>All of above
                     76: </DL>
2.1       frystyk    77: 
                     78: <PRE>
2.17      frystyk    79: typedef int HTNetCallBack (HTRequest * request, int status);
                     80: 
                     81: extern BOOL HTNet_register (HTNetCallBack *cbf, int status);
2.9       frystyk    82: </PRE>
                     83: 
2.17      frystyk    84: <H3>Unregister</H3>
2.9       frystyk    85: 
2.17      frystyk    86: Unregister call back functions
2.9       frystyk    87: 
                     88: <PRE>
2.17      frystyk    89: extern BOOL HTNet_unregister (HTNetCallBack *cbf);
                     90: extern BOOL HTNet_unregisterAll (void);
2.1       frystyk    91: </PRE>
                     92: 
2.17      frystyk    93: <H2>Call the Call Back Functions</H2>
2.10      frystyk    94: 
2.17      frystyk    95: Call all the call back functions registered in the list IF not the
                     96: status is HT_IGNORE. The callback functions are called in the reverse
                     97: order of which they were registered (last one first). Returns YES if
                     98: OK, else NO.
2.10      frystyk    99: 
                    100: <PRE>
2.17      frystyk   101: extern BOOL HTNet_callback (HTRequest * me, int status);
2.10      frystyk   102: </PRE>
                    103: 
2.17      frystyk   104: <H2>Request Queue</H2>
                    105: 
                    106: The request queue ensures that no more than a fixed number of TCP
                    107: connections are open at the same time. If more requests are handed to
                    108: the Library, they are put into the pending queue and initiated when
                    109: sockets become free.
                    110: 
                    111: <H3>Number of Simultanous open TCP connections</H3>
2.1       frystyk   112: 
2.17      frystyk   113: Set the max number of simultanous sockets. The default value is
2.19      frystyk   114: HT_MAX_SOCKETS which is 6. The number of persistent connections depend
                    115: on this value as a deadlock can occur if all available sockets a
                    116: persistent (see the <A HREF="HTDNS.html">DNS Manager</A> for more
                    117: information on setting the number of persistent connections). The
                    118: number of persistent connections can never be more than the max number
                    119: of sockets-2, so letting newmax=2 prevents persistent sockets.
2.1       frystyk   120: 
                    121: <PRE>
2.17      frystyk   122: extern BOOL HTNet_setMaxSocket (int newmax);
                    123: extern int  HTNet_maxSocket (void);
2.1       frystyk   124: </PRE>
                    125: 
2.17      frystyk   126: <H2>List Active Queue</H2>
2.1       frystyk   127: 
2.17      frystyk   128: Returns the list of active requests that are currently having an open
                    129: connection. Returns list of HTNet objects or NULL if error
2.1       frystyk   130: 
                    131: <PRE>
2.17      frystyk   132: extern HTList *HTNet_activeQueue (void);
2.21    ! frystyk   133: extern int HTNet_activeCount (void);
2.1       frystyk   134: </PRE>
2.17      frystyk   135: 
                    136: <H2>List Pending Queue</H2>
                    137: 
                    138: Returns the list of pending requests that are waiting to become
                    139: active. Returns list of HTNet objects or NULL if error
                    140: 
2.1       frystyk   141: <PRE>
2.17      frystyk   142: extern HTList *HTNet_pendingQueue (void);
2.1       frystyk   143: </PRE>
                    144: 
2.17      frystyk   145: <H2>HTNet Object Creation and deletion methods</H2>
                    146: 
                    147: These methods are used from within the Request Manager and are not
                    148: normally to be used outside the Library kernel.
                    149: 
                    150: <H3>Create an Object</H3>
                    151: 
                    152: Create a new HTNet object as a new request to be handled. If we have
                    153: more than HTMaxActive connections already then put this into the
                    154: pending queue, else start the request by calling the call back
                    155: function registered with this access method.  Returns YES if OK, else
                    156: NO
                    157: 
                    158: <PRE>
                    159: extern BOOL HTNet_new (HTRequest * request, HTPriority priority);
2.20      frystyk   160: </PRE>
                    161: 
                    162: <H3>Duplicate an Existing Object</H3>
                    163: 
                    164: Creates a new HTNet object as a duplicate of the same request.
                    165: Returns YES if OK, else NO.
                    166: 
                    167: <PRE>
                    168: extern BOOL HTNet_dup (HTNet *src, HTNet **dest);
2.17      frystyk   169: </PRE>
                    170: 
2.19      frystyk   171: <H2>Make an Object Wait</H2>
                    172: 
                    173: Let a net object wait for a persistent socket. It will be launched
                    174: from the HTNet_delete() function when the socket gets free.
                    175: 
                    176: <PRE>
                    177: extern BOOL HTNet_wait (HTNet *net);
                    178: </PRE>
                    179: 
2.17      frystyk   180: <H3>Delete an Object</H3>
                    181: 
                    182: Deletes the HTNet object from the list of active requests and calls
                    183: any registered call back functions IF not the status is HT_IGNORE.
                    184: This is used if we have internal requests that the app doesn't know
                    185: about. We also see if we have pending requests that can be started up
                    186: now when we have a socket free. The callback functions are called in
                    187: the reverse order of which they were registered (last one first)
2.1       frystyk   188: 
                    189: <PRE>
2.17      frystyk   190: extern BOOL HTNet_delete (HTNet * me, int status);
2.1       frystyk   191: </PRE>
                    192: 
2.17      frystyk   193: <H3>Delete ALL HTNet Objects</H3>
2.1       frystyk   194: 
2.17      frystyk   195: Deletes all HTNet object that might either be active or pending We DO
2.19      frystyk   196: NOT call the call back functions - A crude way of saying goodbye!
2.1       frystyk   197: 
                    198: <PRE>
2.17      frystyk   199: extern BOOL HTNet_deleteAll (void);
2.1       frystyk   200: </PRE>
                    201: 
2.17      frystyk   202: <H2>Killing requests</H2>
                    203: 
                    204: For those who can't help it ;-)
                    205: 
                    206: <H3>Kill a Request</H3>
2.1       frystyk   207: 
2.17      frystyk   208: Kill the request by calling the call back function with a request for
                    209: closing the connection. Does not remove the object. This is done by
                    210: HTNet_delete() function which is called by the load routine.  Returns
                    211: OK if success, NO on error
2.1       frystyk   212: 
                    213: <PRE>
2.17      frystyk   214: extern BOOL HTNet_kill (HTNet * me);
2.1       frystyk   215: </PRE>
                    216: 
2.17      frystyk   217: <H3>Kill ALL requests</H3>
2.1       frystyk   218: 
2.17      frystyk   219: Kills all registered (active+pending) requests by calling the call
                    220: back function with a request for closing the connection. We do not
                    221: remove the HTNet object as it is done by HTNet_delete().  Returns OK
                    222: if success, NO on error
2.1       frystyk   223: 
                    224: <PRE>
2.17      frystyk   225: extern BOOL HTNet_killAll (void);
                    226: </PRE>
2.1       frystyk   227: 
2.17      frystyk   228: <PRE>
                    229: #endif /* HTNET_H */
2.1       frystyk   230: </PRE>
                    231: 
2.17      frystyk   232: End of declaration module
2.1       frystyk   233: </BODY>
                    234: </HTML>
                    235: 
                    236: 

Webmaster