Annotation of libwww/Library/src/HTEvntrg.html, revision 2.10

2.1       cbrooks     1: <HTML>
                      2: <HEAD>
2.7       frystyk     3: <TITLE>Event Manager</TITLE>
2.9       frystyk     4: <!-- Changed by: Henrik Frystyk Nielsen,  2-Oct-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.8       frystyk    31: </PRE>
                     32: 
2.7       frystyk    33: <H2>Event Handlers</H2>
2.1       cbrooks    34: 
                     35: The appplication registers a set of event handlers to be used on a
                     36: specified set of sockets. The eventhandlers must be defined as follows:
                     37: 
                     38: <PRE>
2.7       frystyk    39: typedef u_long SockOps; 
                     40: typedef u_long HTPriority; 
2.1       cbrooks    41: 
2.7       frystyk    42: #define FD_NONE        0
                     43: #define FD_ALL (FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT |FD_CLOSE)
                     44: #define FD_UNREGISTER (((FD_ALL) &lt;&lt; 1) & (~(FD_ALL)))
2.1       cbrooks    45: 
2.10    ! frystyk    46: typedef int HTEventCallback (SOCKET, HTRequest *, SockOps);
2.1       cbrooks    47: </PRE>
                     48: 
2.7       frystyk    49: <H3>Register a TTY Event Handler</H3>
2.1       cbrooks    50: 
2.7       frystyk    51: Register the tty (console) as having events. If the TTY is
                     52: select()-able (as is true under Unix), then we treat it as just
2.8       frystyk    53: another socket. Otherwise, take steps depending on the platform. This
                     54: is the function to use to register user events!
2.1       cbrooks    55: 
                     56: <PRE>
2.7       frystyk    57: extern int HTEvent_RegisterTTY (SOCKET, HTRequest *, SockOps,
2.10    ! frystyk    58:                                 HTEventCallback *, HTPriority);
2.1       cbrooks    59: </PRE>
                     60: 
2.7       frystyk    61: <H3>Unregister a TTY Event Handler</H3>
                     62: 
                     63: Unregisters TTY I/O channel. If the TTY is select()-able (as is true
                     64: under Unix), then we treat it as just another socket.
2.1       cbrooks    65: 
                     66: <PRE>
2.7       frystyk    67: extern int HTEvent_UnRegisterTTY (SOCKET, SockOps);
2.1       cbrooks    68: </PRE>
                     69: 
2.7       frystyk    70: <H3>Register an Event Handler</H3>
2.1       cbrooks    71: 
2.7       frystyk    72: For a given socket, reqister a request structure, a set of operations,
2.10    ! frystyk    73: a HTEventCallback function, and a priority. For this implementation,
        !            74: we allow only a single HTEventCallback function for all operations.
2.7       frystyk    75: and the priority field is ignored.
2.1       cbrooks    76: 
                     77: <PRE>
2.7       frystyk    78: extern int HTEvent_Register    (SOCKET, HTRequest *,
2.10    ! frystyk    79:                                 SockOps, HTEventCallback *,
2.7       frystyk    80:                                 HTPriority);
2.1       cbrooks    81: </PRE>
                     82: 
2.7       frystyk    83: <H3>Unregister an Event Handler</H3>
                     84: 
                     85: Remove the registered information for the specified socket for the
                     86: actions specified in ops. if no actions remain after the unregister,
                     87: the registered info is deleted, and, if the socket has been registered
2.10    ! frystyk    88: for notification, the HTEventCallback will be invoked.
2.1       cbrooks    89: 
                     90: <PRE>
2.7       frystyk    91: extern int HTEvent_UnRegister  (SOCKET, SockOps);
2.1       cbrooks    92: </PRE>
                     93: 
2.7       frystyk    94: <H3>Unregister ALL Event Handlers</H3>
2.1       cbrooks    95: 
2.7       frystyk    96: Unregister all sockets. N.B. we just remove them for our internal data
                     97: structures: it is up to the application to actually close the socket.
2.1       cbrooks    98: 
                     99: <PRE>
2.7       frystyk   100: extern int HTEvent_UnregisterAll (void);
2.9       frystyk   101: </PRE>
                    102: 
                    103: <H2>Handler for Timeout on Sockets</H2>
                    104: 
                    105: This function sets the timeout for sockets in the
                    106: <CODE>select()</CODE> call and registers a timeout function that is
                    107: called if select times out. This does only works on NON windows
                    108: platforms as we need to poll for the console on windows If <CODE>tv =
                    109: NULL</CODE> then timeout is disabled. Default is no timeout. If
                    110: <EM>always=YES</EM> then the callback is called at all times, if NO
                    111: then only when Library sockets are active. Returns YES if OK else NO.
                    112: 
                    113: <PRE>
                    114: typedef int HTEventTimeout (HTRequest *);
                    115: 
                    116: extern BOOL HTEvent_registerTimeout (struct timeval *tp, HTRequest * request,
                    117:                                     HTEventTimeout *tcbf, BOOL always);
2.1       cbrooks   118: </PRE>
                    119: 
2.7       frystyk   120: <H2>Eventloop</H2>
2.1       cbrooks   121: 
2.7       frystyk   122: That is, we wait for activity from one of our registered channels, and
                    123: dispatch on that. Under Windows/NT, we must treat the console and
                    124: sockets as distinct.  That means we can't avoid a busy wait, but we do
                    125: our best.
2.1       cbrooks   126: 
                    127: <PRE>
2.7       frystyk   128: extern int HTEvent_Loop (HTRequest * request);
2.1       cbrooks   129: </PRE>
                    130: 
                    131: 
                    132: <PRE>
                    133: #endif /* HTEvent_H */
                    134: </PRE>
                    135: 
2.7       frystyk   136: End of declartion module
2.1       cbrooks   137: 
                    138: </BODY>
                    139: </HTML>

Webmaster