Annotation of libwww/Library/src/HTNet.html, revision 2.9
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.9 ! frystyk 58: extern BOOL HTThread_new PARAMS((HTNetInfo * new_net));
! 59: extern BOOL HTThread_clear PARAMS((HTNetInfo * old_net));
! 60: </PRE>
! 61:
! 62: <H2>Kill a Thread</H2>
! 63:
! 64: This function forces a call to the load function and resets the state
! 65: machine. It also removes the thread from the list of active threads.
! 66:
! 67: <PRE>
! 68: extern BOOL HTThread_kill PARAMS((HTNetInfo * net));
2.1 frystyk 69: </PRE>
70:
2.7 frystyk 71: <H2>Get Copy of Registered Bit-arrays</H2>
2.1 frystyk 72:
73: This function returns a copy of the current bit-arrays contaning the
74: active sockets registered for <CODE>READ</CODE> and
75: <CODE>WRITE</CODE>.
76:
77: <PRE>
2.3 frystyk 78: extern int HTThreadGetFDInfo PARAMS((fd_set * read, fd_set * write));
2.1 frystyk 79: </PRE>
80:
81: <H2>Registration of the State of a Socket</H2>
82:
83: When a new request is initiated from the client and a socket has been
84: created, is gets registered in a linked list of <A
85: HREF="HTAccess.html#HTNetInfo">HTNetInfo objects</A>. The object stays
86: in this list until the request has ended (either having an error or
87: success as result). Every time the program execution gets to a point
88: where a socket operation would normally block the program, this
89: function is called in order to register the socket as waiting for the
90: actual operation.
91:
92: <PRE>
93: typedef enum _HTThreadAction {
2.5 frystyk 94: THD_SET_WRITE=0,
2.1 frystyk 95: THD_CLR_WRITE,
96: THD_SET_READ,
97: THD_CLR_READ,
2.4 frystyk 98: THD_SET_INTR,
99: THD_CLR_INTR,
2.1 frystyk 100: THD_CLOSE
101: } HTThreadAction;
102: </PRE>
103:
104: <PRE>
2.9 ! frystyk 105: extern void HTThreadState PARAMS((SOCKFD sockfd, HTThreadAction action));
2.1 frystyk 106: </PRE>
107:
108: This function makes life easier if you want to mark all sockets as
109: interrupted.
110:
111: <PRE>
2.9 ! frystyk 112: extern BOOL HTThreadMarkIntrAll PARAMS((CONST fd_set * fd_user));
2.1 frystyk 113: </PRE>
114:
115: <H2>Is a Thread Interrupted?</H2>
116:
117: This function returns YES if the socket is registered as interrupted
118:
119: <PRE>
2.6 frystyk 120: extern BOOL HTThreadIntr PARAMS((SOCKFD sockfd));
2.1 frystyk 121: </PRE>
122:
123: <H2>Any Threads Registered?</H2>
124:
125: This function returns YES if any HTTP sockets are still registered in the
126: set of active sockets. Otherwise it returns NO.
127:
128: <PRE>
2.4 frystyk 129: extern BOOL HTThreadActive NOPARAMS;
2.1 frystyk 130: </PRE>
131:
132: <H2>Select an Active Thread</H2>
133:
134: When the <CODE>select</CODE> function has returned a set of pending
135: sockets this functions selects one of them and finds the
136: correseponding request structure.
137:
138: <PRE>
2.3 frystyk 139: extern HTRequest *HTThread_getRequest PARAMS((CONST fd_set * fd_read,
2.1 frystyk 140: CONST fd_set * fd_write));
141:
142: #endif
143: </PRE>
144:
145: End of HTThread module
146: </BODY>
147: </HTML>
148:
149:
Webmaster