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

2.1     ! frystyk     1: <HTML>
        !             2: <HEAD>
        !             3: <TITLE>Multi-Threaded Management</TITLE>
        !             4: <NEXTID N="z100">
        !             5: </HEAD>
        !             6: <BODY>
        !             7: <H1>Multi Threaded Sockets</H1>
        !             8: 
        !             9: This module contains the routines for handling the set of active
        !            10: sockets currently in use by the multi-threaded clients. Look for more
        !            11: information in the <A
        !            12: HREF="http://info.cern.ch/hypertext/WWW/Library/User/Multithread/multithread.html">
        !            13: Multi-Thread Specifications</A>. <P>
        !            14: 
        !            15: This module is implemented by <A HREF="HTThread.c">HTThread.c</A>, and
        !            16: it is a part of the <A NAME="z10"
        !            17: HREF="http://info.cern.ch/hypertext/WWW/Library/User/Guide/Guide.html">Library
        !            18: of Common Code</A>.
        !            19: 
        !            20: <PRE>
        !            21: #ifndef HTTHREAD_H
        !            22: #define HTTHREAD_H
        !            23: #include "HTAccess.h"
        !            24: </PRE>
        !            25: 
        !            26: <A NAME="Init"><H2>Initiation</H2></A>
        !            27: 
        !            28: This function initiates the arrays of socket descriptors used in the
        !            29: Library. It is currently done in the private <A
        !            30: HREF="HTAccess.html#ProtReg">HTAccessInit</A> function. <P>
        !            31: 
        !            32: <B>Note:</B> It is <B>VERY</B> important that this one is called
        !            33: before the first request.
        !            34: 
        !            35: <PRE>
        !            36: PUBLIC BOOL HTThreadInit       NOPARAMS;
        !            37: </PRE>
        !            38: 
        !            39: <H2>Registration of a Thread</H2>
        !            40: 
        !            41: These two functions put a <A HREF="HTAccess.html#HTNetInfo">HTNetInfo
        !            42: object</A> into the list of threads and takes it out again
        !            43: respectively. A normal place to call these functions would be on
        !            44: creation and deletion of the data objects.
        !            45: 
        !            46: <PRE>
        !            47: PUBLIC void HTThread_new       PARAMS((HTNetInfo * new_net));
        !            48: PUBLIC int  HTThread_clear     PARAMS((HTNetInfo * old_net));
        !            49: </PRE>
        !            50: 
        !            51: <H2>Get Bit-arrays for Select()</H2>
        !            52: 
        !            53: This function returns a copy of the current bit-arrays contaning the
        !            54: active sockets registered for <CODE>READ</CODE> and
        !            55: <CODE>WRITE</CODE>.
        !            56: 
        !            57: <PRE>
        !            58: PUBLIC int HTThreadGetFDInfo   PARAMS((fd_set * read, fd_set * write));
        !            59: </PRE>
        !            60: 
        !            61: 
        !            62: 
        !            63: <H2>Registration of the State of a Socket</H2>
        !            64: 
        !            65: When a new request is initiated from the client and a socket has been
        !            66: created, is gets registered in a linked list of <A
        !            67: HREF="HTAccess.html#HTNetInfo">HTNetInfo objects</A>. The object stays
        !            68: in this list until the request has ended (either having an error or
        !            69: success as result). Every time the program execution gets to a point
        !            70: where a socket operation would normally block the program, this
        !            71: function is called in order to register the socket as waiting for the
        !            72: actual operation.
        !            73: 
        !            74: <PRE>
        !            75: 
        !            76: extern int     HTMaxfdpl;
        !            77: 
        !            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