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