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