Annotation of libwww/Library/src/HTChannl.html, revision 2.2

2.1       frystyk     1: <HTML>
                      2: <HEAD>
2.2     ! frystyk     3:   <TITLE>W3C Reference Library libwww Channel Class</TITLE>
2.1       frystyk     4: </HEAD>
                      5: <BODY>
2.2     ! frystyk     6: <H1>
        !             7:   The Channel Class
        !             8: </H1>
2.1       frystyk     9: <PRE>
                     10: /*
                     11: **     (c) COPYRIGHT MIT 1995.
                     12: **     Please first read the full copyright statement in the file COPYRIGH.
                     13: */
                     14: </PRE>
2.2     ! frystyk    15: <P>
        !            16: A channel contains information about sockets and their input and output streams.
        !            17: A <CODE>channel</CODE> represents the front end for receiving data towards
        !            18: the underlying transport. The definition of a channel describes how we are
        !            19: to read the data coming in on a socket, for example. In other words - a channel
        !            20: represents the first part of how to get handle incoming data in the Library:
        !            21: <P>
2.1       frystyk    22: <UL>
2.2     ! frystyk    23:   <LI>
        !            24:     Reading data on a channel
        !            25:   <LI>
        !            26:     Defining a target for incoming data
        !            27:   <LI>
        !            28:     Defining a protocol state machine that can handle the data
2.1       frystyk    29: </UL>
2.2     ! frystyk    30: <P>
        !            31: This module is implemented by <A HREF="HTChannl.c">HTChannl.c</A>, and it
        !            32: is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C Reference
        !            33: Library</A>.
2.1       frystyk    34: <PRE>
                     35: #ifndef HTCHANNL_H
                     36: #define HTCHANNL_H
                     37: 
                     38: typedef enum _HTChannelMode {
                     39:     HT_CH_SINGLE       = 0,            /* One single request at a time */
                     40:     HT_CH_BATCH                = 1,            /* Use batch requests */
                     41:     HT_CH_INTERLEAVED  = 2             /* Can we interleave requests? */
                     42: } HTChannelMode;
                     43: 
                     44: typedef struct _HTChannel HTChannel;
                     45: 
                     46: #include <A HREF="HTTrans.html">"HTTrans.h"</A>
                     47: #include <A HREF="HTReq.html">"HTReq.h"</A>
                     48: #include <A HREF="HTNet.html">"HTNet.h"</A>
                     49: #include <A HREF="HTIOStream.html">"HTIOStream.h"</A>
                     50: </PRE>
2.2     ! frystyk    51: <H2>
        !            52:   The Channel Object
        !            53: </H2>
        !            54: <P>
        !            55: A channel can be in a certain <CODE>mode</CODE> which determines how it behaves.
        !            56: The set of modes is defined as:
        !            57: <H3>
        !            58:   Creating a Channel Object
        !            59: </H3>
        !            60: <P>
        !            61: The following methods can be used to instantiate objects of a particular
        !            62: channel mode:
2.1       frystyk    63: <PRE>
                     64: extern HTChannel * HTChannel_new (HTNet * net, BOOL active);
                     65: </PRE>
2.2     ! frystyk    66: <H3>
        !            67:   Deleting a Channel Object
        !            68: </H3>
2.1       frystyk    69: <PRE>
                     70: extern BOOL HTChannel_delete (HTChannel * channel);
                     71: extern BOOL HTCannel_deleteAll (void);
                     72: </PRE>
2.2     ! frystyk    73: <H3>
        !            74:   Control the Channel Mode
        !            75: </H3>
        !            76: <P>
        !            77: A channel may change mode in the middle of a connection. The mode signifies
        !            78: how we can use the channel: Does it accept multiple requets at the same time
        !            79: or do we have to wait until a response is received? Can it handle interleaved
        !            80: (multiplexed) requests/responses etc. All this is defined by the
        !            81: <CODE>HTChannelMode</CODE>. At the same time we return whether the channel
        !            82: is active or passive which means whether we did the initial "connect" or
        !            83: the "accept". The "connect" and the "accept" term is of course a function
        !            84: of the underlying transport but I think you get the point!
2.1       frystyk    85: <PRE>
                     86: extern HTChannelMode HTChannel_mode (HTChannel * channel, BOOL * active);
                     87: 
                     88: extern BOOL HTChannel_setMode (HTChannel * channel, HTChannelMode mode);
                     89: </PRE>
2.2     ! frystyk    90: <H3>
        !            91:   Search for a Channel
        !            92: </H3>
        !            93: <P>
2.1       frystyk    94: Look for a channel object if we for some reason should have lost it
                     95: <PRE>
                     96: extern HTChannel * HTChannel_find (SOCKET sockfd);
                     97: </PRE>
2.2     ! frystyk    98: <H3>
        !            99:   Is the Channel Idle?
        !           100: </H3>
        !           101: <P>
        !           102: Check whether a channel is idle meaning if it is ready for a new request
        !           103: which depends on the mode of the channel. If the channel is idle, i.e. ready
        !           104: for use then return YES else NO.
2.1       frystyk   105: <PRE>
                    106: extern BOOL HTChannel_idle (HTChannel * channel);
                    107: </PRE>
2.2     ! frystyk   108: <H3>
        !           109:   Get Transport Descriptor for Channel
        !           110: </H3>
        !           111: <P>
        !           112: A transport descriptor can be either a ANSI C file descriptor or a BSD socket.
        !           113: As it is difficult for the channel to know which one is used by a specific
        !           114: transport, we leave this to the caller to figure out. This is probably not
        !           115: the best way of doing it.
        !           116: <PRE>extern SOCKET HTChannel_socket    (HTChannel * channel);
        !           117: extern FILE * HTChannel_file   (HTChannel * channel);
        !           118: 
        !           119: </PRE>
        !           120: <H3>
        !           121:   Semaphores
        !           122: </H3>
        !           123: <P>
        !           124: Adjust the semaphore on a channel. As many <A HREF="HTNet.html">Net objects
        !           125: </A>can point to the same channel we need to keep count of them so that we
        !           126: know if we can delete a channel or if it is still in use. We do this by having
        !           127: a simple semaphore associated with each channel object
2.1       frystyk   128: <PRE>
                    129: extern void HTChannel_upSemaphore (HTChannel * channel);
                    130: extern void HTChannel_downSemaphore (HTChannel * channel);
                    131: </PRE>
2.2     ! frystyk   132: <H3>
        !           133:   Create Input and Output Streams
        !           134: </H3>
        !           135: <P>
        !           136: You create the input stream and bind it to the channel using the following
        !           137: methods. Please read the description in the
        !           138: <A HREF="HTIOStream.html">HTIOStream module</A> on the parameters
        !           139: <EM>target</EM>, <EM>param</EM>, and <EM>mode</EM>. The input and output
        !           140: stream are instances created by the <A HREF="HTTrans.html">Transport
        !           141: object</A>. The Transport Object defines the creation methods for the inout
        !           142: and output streams and the Channel object contains the actualy stream objects.
2.1       frystyk   143: <PRE>
                    144: extern BOOL HTChannel_setInput (HTChannel * ch,
                    145:                                HTInputStream * input, HTChannelMode mode);
2.2     ! frystyk   146: extern HTInputStream * HTChannel_input (HTChannel * ch);
        !           147: 
2.1       frystyk   148: 
                    149: extern BOOL HTChannel_setOutput (HTChannel * ch,
                    150:                                 HTOutputStream * output, HTChannelMode mode);
                    151: extern HTOutputStream * HTChannel_output (HTChannel * ch);
                    152: 
                    153: </PRE>
                    154: <PRE>
                    155: #endif /* HTCHANNL */
                    156: </PRE>
2.2     ! frystyk   157: <P>
        !           158:   <HR>
2.1       frystyk   159: <ADDRESS>
2.2     ! frystyk   160:   @(#) $Id: HTChannl.html,v 2.1 1996/04/12 17:46:13 frystyk Exp $
2.1       frystyk   161: </ADDRESS>
2.2     ! frystyk   162: </BODY></HTML>

Webmaster