Annotation of libwww/Library/src/HTNet.html, revision 2.3
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,
82: THD_INTR,
83: THD_CLOSE
84: } HTThreadAction;
85: </PRE>
86:
87: <PRE>
2.3 ! frystyk 88: extern void HTThreadState PARAMS((int sockfd, HTThreadAction action));
2.1 frystyk 89: </PRE>
90:
91: This function makes life easier if you want to mark all sockets as
92: interrupted.
93:
94: <PRE>
2.3 ! frystyk 95: extern void HTThreadMarkIntrAll NOPARAMS;
2.1 frystyk 96: </PRE>
97:
98: <H2>Is a Thread Interrupted?</H2>
99:
100: This function returns YES if the socket is registered as interrupted
101:
102: <PRE>
2.3 ! frystyk 103: extern BOOL HTThreadIntr PARAMS((int sockfd));
2.1 frystyk 104: </PRE>
105:
106: <H2>Any Threads Registered?</H2>
107:
108: This function returns YES if any HTTP sockets are still registered in the
109: set of active sockets. Otherwise it returns NO.
110:
111: <PRE>
2.3 ! frystyk 112: extern BOOL HTThreadActive NOPARAMS;
2.1 frystyk 113: </PRE>
114:
115: <H2>Select an Active Thread</H2>
116:
117: When the <CODE>select</CODE> function has returned a set of pending
118: sockets this functions selects one of them and finds the
119: correseponding request structure.
120:
121: <PRE>
2.3 ! frystyk 122: extern HTRequest *HTThread_getRequest PARAMS((CONST fd_set * fd_read,
2.1 frystyk 123: CONST fd_set * fd_write));
124:
125: #endif
126: </PRE>
127:
128: End of HTThread module
129: </BODY>
130: </HTML>
131:
132:
Webmaster