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

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: #include "HTAccess.h"
                     27: </PRE>
                     28: 
                     29: <A NAME="Init"><H2>Initiation</H2></A>
                     30: 
                     31: This function initiates the arrays of socket descriptors used in the
                     32: Library. It is currently done in the private <A
                     33: HREF="HTAccess.html#ProtReg">HTAccessInit</A> function. <P>
                     34: 
                     35: <PRE>
                     36: PUBLIC BOOL HTThreadInit       NOPARAMS;
                     37: </PRE>
                     38: 
2.2     ! frystyk    39: <IMG ALT="NOTE"
        !            40: SRC="http://info.cern.ch/hypertext/WWW/Icons/32x32/caution.gif"> It is
        !            41: <B>VERY</B> important that this one is called before the first
        !            42: request, as otherwise the socket bit arrays are uninitialized.
        !            43: 
2.1       frystyk    44: <H2>Registration of a Thread</H2>
                     45: 
                     46: These two functions put a <A HREF="HTAccess.html#HTNetInfo">HTNetInfo
                     47: object</A> into the list of threads and takes it out again
                     48: respectively. A normal place to call these functions would be on
2.2     ! frystyk    49: creation and deletion of the <CODE>HTNetInfo</CODE> data structure.
2.1       frystyk    50: 
                     51: <PRE>
                     52: PUBLIC void HTThread_new       PARAMS((HTNetInfo * new_net));
                     53: PUBLIC int  HTThread_clear     PARAMS((HTNetInfo * old_net));
                     54: </PRE>
                     55: 
                     56: <H2>Get Bit-arrays for Select()</H2>
                     57: 
                     58: This function returns a copy of the current bit-arrays contaning the
                     59: active sockets registered for <CODE>READ</CODE> and
                     60: <CODE>WRITE</CODE>.
                     61: 
                     62: <PRE>
                     63: PUBLIC int HTThreadGetFDInfo   PARAMS((fd_set * read, fd_set * write));
                     64: </PRE>
                     65: 
                     66: <H2>Registration of the State of a Socket</H2>
                     67: 
                     68: When a new request is initiated from the client and a socket has been
                     69: created, is gets registered in a linked list of <A
                     70: HREF="HTAccess.html#HTNetInfo">HTNetInfo objects</A>. The object stays
                     71: in this list until the request has ended (either having an error or
                     72: success as result). Every time the program execution gets to a point
                     73: where a socket operation would normally block the program, this
                     74: function is called in order to register the socket as waiting for the
                     75: actual operation.
                     76: 
                     77: <PRE>
                     78: typedef enum _HTThreadAction {
                     79:     THD_SET_WRITE,
                     80:     THD_CLR_WRITE,
                     81:     THD_SET_READ,
                     82:     THD_CLR_READ,
                     83:     THD_INTR,
                     84:     THD_CLOSE
                     85: } HTThreadAction;
                     86: </PRE>
                     87: 
                     88: <PRE>
                     89: PUBLIC void HTThreadState PARAMS((int sockfd, HTThreadAction action));
                     90: </PRE>
                     91: 
                     92: This function makes life easier if you want to mark all sockets as
                     93: interrupted.
                     94: 
                     95: <PRE>
                     96: PUBLIC void HTThreadMarkIntrAll                NOPARAMS;
                     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>
                    104: PUBLIC BOOL HTThreadIntr PARAMS((int sockfd));
                    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>
                    113: PUBLIC BOOL HTThreadActive NOPARAMS;
                    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>
                    123: PUBLIC HTRequest *HTThread_getRequest  PARAMS((CONST fd_set * fd_read,
                    124:                                                CONST fd_set * fd_write));
                    125: 
                    126: #endif
                    127: </PRE>
                    128: 
                    129: End of HTThread module
                    130: </BODY>
                    131: </HTML>
                    132: 
                    133: 

Webmaster