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

2.1       frystyk     1: <HTML>
                      2: <HEAD>
2.2       frystyk     3: <TITLE>Multithreaded Management</TITLE>
2.1       frystyk     4: <NEXTID N="z100">
                      5: </HEAD>
                      6: <BODY>
2.2       frystyk     7: 
                      8: <H1>Multithreaded Management of Sockets</H1>
2.1       frystyk     9: 
                     10: This module contains the routines for handling the set of active
2.2       frystyk    11: sockets currently in use by the multithreaded clients. It is an
                     12: internal module to the Library, the application interface is
                     13: implemented in the <A HREF="HTEvent.html">Event Module</A>. Look for
                     14: more information in the <A
2.1       frystyk    15: HREF="http://info.cern.ch/hypertext/WWW/Library/User/Multithread/multithread.html">
2.2       frystyk    16: Multithread Specifications</A>. <P>
2.1       frystyk    17: 
                     18: This module is implemented by <A HREF="HTThread.c">HTThread.c</A>, and
                     19: it is a part of the <A NAME="z10"
                     20: HREF="http://info.cern.ch/hypertext/WWW/Library/User/Guide/Guide.html">Library
                     21: of Common Code</A>.
                     22: 
                     23: <PRE>
                     24: #ifndef HTTHREAD_H
                     25: #define HTTHREAD_H
                     26: </PRE>
                     27: 
                     28: <A NAME="Init"><H2>Initiation</H2></A>
                     29: 
                     30: This function initiates the arrays of socket descriptors used in the
                     31: Library. It is currently done in the private <A
                     32: HREF="HTAccess.html#ProtReg">HTAccessInit</A> function. <P>
                     33: 
                     34: <PRE>
2.3       frystyk    35: extern BOOL HTThreadInit       NOPARAMS;
2.1       frystyk    36: </PRE>
                     37: 
2.2       frystyk    38: <IMG ALT="NOTE"
                     39: SRC="http://info.cern.ch/hypertext/WWW/Icons/32x32/caution.gif"> It is
                     40: <B>VERY</B> important that this one is called before the first
                     41: request, as otherwise the socket bit arrays are uninitialized.
                     42: 
2.1       frystyk    43: <H2>Registration of a Thread</H2>
                     44: 
                     45: These two functions put a <A HREF="HTAccess.html#HTNetInfo">HTNetInfo
                     46: object</A> into the list of threads and takes it out again
                     47: respectively. A normal place to call these functions would be on
2.2       frystyk    48: creation and deletion of the <CODE>HTNetInfo</CODE> data structure.
2.1       frystyk    49: 
                     50: <PRE>
2.3       frystyk    51: extern void HTThread_new       PARAMS((HTNetInfo * new_net));
                     52: extern int  HTThread_clear     PARAMS((HTNetInfo * old_net));
2.1       frystyk    53: </PRE>
                     54: 
                     55: <H2>Get Bit-arrays for Select()</H2>
                     56: 
                     57: This function returns a copy of the current bit-arrays contaning the
                     58: active sockets registered for <CODE>READ</CODE> and
                     59: <CODE>WRITE</CODE>.
                     60: 
                     61: <PRE>
2.3       frystyk    62: extern int HTThreadGetFDInfo   PARAMS((fd_set * read, fd_set * write));
2.1       frystyk    63: </PRE>
                     64: 
                     65: <H2>Registration of the State of a Socket</H2>
                     66: 
                     67: When a new request is initiated from the client and a socket has been
                     68: created, is gets registered in a linked list of <A
                     69: HREF="HTAccess.html#HTNetInfo">HTNetInfo objects</A>. The object stays
                     70: in this list until the request has ended (either having an error or
                     71: success as result). Every time the program execution gets to a point
                     72: where a socket operation would normally block the program, this
                     73: function is called in order to register the socket as waiting for the
                     74: actual operation.
                     75: 
                     76: <PRE>
                     77: typedef enum _HTThreadAction {
                     78:     THD_SET_WRITE,
                     79:     THD_CLR_WRITE,
                     80:     THD_SET_READ,
                     81:     THD_CLR_READ,
2.4     ! frystyk    82:     THD_SET_INTR,
        !            83:     THD_CLR_INTR,
2.1       frystyk    84:     THD_CLOSE
                     85: } HTThreadAction;
                     86: </PRE>
                     87: 
                     88: <PRE>
2.3       frystyk    89: extern void HTThreadState PARAMS((int sockfd, HTThreadAction action));
2.1       frystyk    90: </PRE>
                     91: 
                     92: This function makes life easier if you want to mark all sockets as
                     93: interrupted.
                     94: 
                     95: <PRE>
2.4     ! frystyk    96: extern void HTThreadMarkIntrAll        PARAMS((CONST fd_set * fd_user));
2.1       frystyk    97: </PRE>
                     98: 
                     99: <H2>Is a Thread Interrupted?</H2>
                    100: 
                    101: This function returns YES if the socket is registered as interrupted
                    102: 
                    103: <PRE>
2.4     ! frystyk   104: extern BOOL HTThreadIntr       PARAMS((int sockfd));
2.1       frystyk   105: </PRE>
                    106: 
                    107: <H2>Any Threads Registered?</H2>
                    108: 
                    109: This function returns YES if any HTTP sockets are still registered in the
                    110: set of active sockets. Otherwise it returns NO.
                    111: 
                    112: <PRE>
2.4     ! frystyk   113: extern BOOL HTThreadActive     NOPARAMS;
2.1       frystyk   114: </PRE>
                    115: 
                    116: <H2>Select an Active Thread</H2>
                    117: 
                    118: When the <CODE>select</CODE> function has returned a set of pending
                    119: sockets this functions selects one of them and finds the
                    120: correseponding request structure.
                    121: 
                    122: <PRE>
2.3       frystyk   123: extern HTRequest *HTThread_getRequest  PARAMS((CONST fd_set * fd_read,
2.1       frystyk   124:                                                CONST fd_set * fd_write));
                    125: 
                    126: #endif
                    127: </PRE>
                    128: 
                    129: End of HTThread module
                    130: </BODY>
                    131: </HTML>
                    132: 
                    133: 

Webmaster