Annotation of libwww/Library/src/HTEvntrg.html, revision 2.11
2.1 cbrooks 1: <HTML>
2: <HEAD>
2.7 frystyk 3: <TITLE>Event Manager</TITLE>
2.11 ! frystyk 4: <!-- Changed by: Henrik Frystyk Nielsen, 14-Nov-1995 -->
2.1 cbrooks 5: </HEAD>
6: <BODY>
7:
2.7 frystyk 8: <H1>Event Manager</H1>
2.1 cbrooks 9:
10: <PRE>
11: /*
12: ** (c) COPYRIGHT MIT 1995.
13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
16:
17: This module is the application interface to the multi-threaded
18: functionality in the Library. It contains a set of functions that the
19: application can either use as are or they can be overwritten by the
2.7 frystyk 20: application. <P>
2.1 cbrooks 21:
2.3 frystyk 22: This module is implemented by <A HREF="HTEvntrg.c">HTEvntrg.c</A>, and
2.7 frystyk 23: it is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/">W3C
24: Reference Library</A>. <P>
2.1 cbrooks 25:
26: <PRE>
27: #ifndef HTEVNTRG_H
28: #define HTEVNTRG_H
2.9 frystyk 29: #include "HTReq.h"
2.1 cbrooks 30: #include "tcp.h"
2.11 ! frystyk 31: </PRE>
! 32:
! 33: <H2>Windows Specific Handles</H2>
! 34:
! 35: <PRE>
! 36: #ifdef WWW_WIN_ASYNC
! 37: extern BOOL HTEvent_winHandle (HTRequest * request);
! 38: extern BOOL HTEvent_setWinHandle (HWND window, unsigned long message);
! 39: #endif
2.8 frystyk 40: </PRE>
41:
2.7 frystyk 42: <H2>Event Handlers</H2>
2.1 cbrooks 43:
44: The appplication registers a set of event handlers to be used on a
45: specified set of sockets. The eventhandlers must be defined as follows:
46:
47: <PRE>
2.7 frystyk 48: typedef u_long SockOps;
49: typedef u_long HTPriority;
2.1 cbrooks 50:
2.7 frystyk 51: #define FD_NONE 0
52: #define FD_ALL (FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT |FD_CLOSE)
53: #define FD_UNREGISTER (((FD_ALL) << 1) & (~(FD_ALL)))
2.1 cbrooks 54:
2.10 frystyk 55: typedef int HTEventCallback (SOCKET, HTRequest *, SockOps);
2.1 cbrooks 56: </PRE>
57:
2.7 frystyk 58: <H3>Register a TTY Event Handler</H3>
2.1 cbrooks 59:
2.7 frystyk 60: Register the tty (console) as having events. If the TTY is
61: select()-able (as is true under Unix), then we treat it as just
2.8 frystyk 62: another socket. Otherwise, take steps depending on the platform. This
63: is the function to use to register user events!
2.1 cbrooks 64:
65: <PRE>
2.7 frystyk 66: extern int HTEvent_RegisterTTY (SOCKET, HTRequest *, SockOps,
2.10 frystyk 67: HTEventCallback *, HTPriority);
2.1 cbrooks 68: </PRE>
69:
2.7 frystyk 70: <H3>Unregister a TTY Event Handler</H3>
71:
72: Unregisters TTY I/O channel. If the TTY is select()-able (as is true
73: under Unix), then we treat it as just another socket.
2.1 cbrooks 74:
75: <PRE>
2.7 frystyk 76: extern int HTEvent_UnRegisterTTY (SOCKET, SockOps);
2.1 cbrooks 77: </PRE>
78:
2.7 frystyk 79: <H3>Register an Event Handler</H3>
2.1 cbrooks 80:
2.7 frystyk 81: For a given socket, reqister a request structure, a set of operations,
2.10 frystyk 82: a HTEventCallback function, and a priority. For this implementation,
83: we allow only a single HTEventCallback function for all operations.
2.7 frystyk 84: and the priority field is ignored.
2.1 cbrooks 85:
86: <PRE>
2.7 frystyk 87: extern int HTEvent_Register (SOCKET, HTRequest *,
2.10 frystyk 88: SockOps, HTEventCallback *,
2.7 frystyk 89: HTPriority);
2.1 cbrooks 90: </PRE>
91:
2.7 frystyk 92: <H3>Unregister an Event Handler</H3>
93:
94: Remove the registered information for the specified socket for the
95: actions specified in ops. if no actions remain after the unregister,
96: the registered info is deleted, and, if the socket has been registered
2.10 frystyk 97: for notification, the HTEventCallback will be invoked.
2.1 cbrooks 98:
99: <PRE>
2.7 frystyk 100: extern int HTEvent_UnRegister (SOCKET, SockOps);
2.1 cbrooks 101: </PRE>
102:
2.7 frystyk 103: <H3>Unregister ALL Event Handlers</H3>
2.1 cbrooks 104:
2.7 frystyk 105: Unregister all sockets. N.B. we just remove them for our internal data
106: structures: it is up to the application to actually close the socket.
2.1 cbrooks 107:
108: <PRE>
2.7 frystyk 109: extern int HTEvent_UnregisterAll (void);
2.9 frystyk 110: </PRE>
111:
112: <H2>Handler for Timeout on Sockets</H2>
113:
114: This function sets the timeout for sockets in the
115: <CODE>select()</CODE> call and registers a timeout function that is
116: called if select times out. This does only works on NON windows
117: platforms as we need to poll for the console on windows If <CODE>tv =
118: NULL</CODE> then timeout is disabled. Default is no timeout. If
119: <EM>always=YES</EM> then the callback is called at all times, if NO
120: then only when Library sockets are active. Returns YES if OK else NO.
121:
122: <PRE>
123: typedef int HTEventTimeout (HTRequest *);
124:
125: extern BOOL HTEvent_registerTimeout (struct timeval *tp, HTRequest * request,
126: HTEventTimeout *tcbf, BOOL always);
2.1 cbrooks 127: </PRE>
128:
2.7 frystyk 129: <H2>Eventloop</H2>
2.1 cbrooks 130:
2.7 frystyk 131: That is, we wait for activity from one of our registered channels, and
132: dispatch on that. Under Windows/NT, we must treat the console and
133: sockets as distinct. That means we can't avoid a busy wait, but we do
134: our best.
2.1 cbrooks 135:
136: <PRE>
2.7 frystyk 137: extern int HTEvent_Loop (HTRequest * request);
2.1 cbrooks 138: </PRE>
139:
140:
141: <PRE>
142: #endif /* HTEvent_H */
143: </PRE>
144:
2.7 frystyk 145: End of declartion module
2.1 cbrooks 146:
147: </BODY>
148: </HTML>
Webmaster