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

2.1       frystyk     1: <HTML>
                      2: <HEAD>
2.9     ! frystyk     3:   <TITLE>W3C Sample Code Library libwww Channel Interface</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
2.9     ! frystyk    32: is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C Sample Code
2.2       frystyk    33: Library</A>.
2.1       frystyk    34: <PRE>
                     35: #ifndef HTCHANNL_H
                     36: #define HTCHANNL_H
                     37: 
                     38: typedef struct _HTChannel HTChannel;
                     39: 
2.6       frystyk    40: #include <A HREF="HTHost.html">"HTHost.h"</A>
2.1       frystyk    41: #include <A HREF="HTIOStream.html">"HTIOStream.h"</A>
                     42: </PRE>
2.2       frystyk    43: <H2>
                     44:   The Channel Object
                     45: </H2>
                     46: <P>
2.6       frystyk    47: The channel object contains an input and an output stream for a particular
                     48: connection.
2.2       frystyk    49: <H3>
2.6       frystyk    50:   Creation and Deletion of Channel Objects
2.2       frystyk    51: </H3>
2.8       frystyk    52: 
                     53: Either the socket can be invalid (INVSOC) or the file descriptor can
                     54: be NULL but not both.
                     55: 
2.1       frystyk    56: <PRE>
2.8       frystyk    57: extern HTChannel * HTChannel_new (SOCKET sockfd, FILE * fp, BOOL active);
2.1       frystyk    58: </PRE>
2.2       frystyk    59: <H3>
                     60:   Deleting a Channel Object
                     61: </H3>
2.1       frystyk    62: <PRE>
2.3       eric       63: extern BOOL HTChannel_delete (HTChannel * channel, int status);
2.5       frystyk    64: extern BOOL HTChannel_deleteAll (void);
2.1       frystyk    65: </PRE>
2.2       frystyk    66: <H3>
                     67:   Search for a Channel
                     68: </H3>
                     69: <P>
2.1       frystyk    70: Look for a channel object if we for some reason should have lost it
                     71: <PRE>
                     72: extern HTChannel * HTChannel_find (SOCKET sockfd);
                     73: </PRE>
2.2       frystyk    74: <H3>
                     75:   Get Transport Descriptor for Channel
                     76: </H3>
                     77: <P>
                     78: A transport descriptor can be either a ANSI C file descriptor or a BSD socket.
                     79: As it is difficult for the channel to know which one is used by a specific
                     80: transport, we leave this to the caller to figure out. This is probably not
                     81: the best way of doing it.
2.7       frystyk    82: <PRE>
                     83: extern SOCKET HTChannel_socket (HTChannel * channel);
2.8       frystyk    84: extern BOOL HTChannel_setSocket        (HTChannel * channel, SOCKET socket);
                     85: 
2.2       frystyk    86: extern FILE * HTChannel_file   (HTChannel * channel);
2.8       frystyk    87: extern BOOL HTChannel_setFile   (HTChannel * channel, FILE * fp);
2.6       frystyk    88: </PRE>
                     89: <H3>
                     90:   The Host Object
                     91: </H3>
                     92: <P>
                     93: The Channel object also keeps a link to the <A HREF="HTHost.html">host
                     94: object</A> so that we have a link to the persistent connection repository.
                     95: <PRE>extern BOOL HTChannel_setHost (HTChannel * ch, HTHost * host);
                     96: extern HTHost * HTChannel_host (HTChannel * ch);
2.2       frystyk    97: </PRE>
                     98: <H3>
                     99:   Semaphores
                    100: </H3>
                    101: <P>
                    102: Adjust the semaphore on a channel. As many <A HREF="HTNet.html">Net objects
                    103: </A>can point to the same channel we need to keep count of them so that we
                    104: know if we can delete a channel or if it is still in use. We do this by having
                    105: a simple semaphore associated with each channel object
2.1       frystyk   106: <PRE>
2.4       frystyk   107: extern void HTChannel_upSemaphore   (HTChannel * channel);
2.1       frystyk   108: extern void HTChannel_downSemaphore (HTChannel * channel);
2.4       frystyk   109: extern void HTChannel_setSemaphore  (HTChannel * channel, int semaphore);
2.1       frystyk   110: </PRE>
2.2       frystyk   111: <H3>
                    112:   Create Input and Output Streams
                    113: </H3>
                    114: <P>
                    115: You create the input stream and bind it to the channel using the following
                    116: methods. Please read the description in the
                    117: <A HREF="HTIOStream.html">HTIOStream module</A> on the parameters
                    118: <EM>target</EM>, <EM>param</EM>, and <EM>mode</EM>. The input and output
                    119: stream are instances created by the <A HREF="HTTrans.html">Transport
                    120: object</A>. The Transport Object defines the creation methods for the inout
                    121: and output streams and the Channel object contains the actualy stream objects.
2.1       frystyk   122: <PRE>
2.6       frystyk   123: extern BOOL HTChannel_setInput (HTChannel * ch, HTInputStream * input);
2.2       frystyk   124: extern HTInputStream * HTChannel_input (HTChannel * ch);
                    125: 
2.6       frystyk   126: extern BOOL HTChannel_setOutput (HTChannel * ch, HTOutputStream * output);
2.1       frystyk   127: extern HTOutputStream * HTChannel_output (HTChannel * ch);
2.7       frystyk   128: 
                    129: extern HTInputStream * HTChannel_getChannelIStream (HTChannel * ch);
                    130: extern HTOutputStream * HTChannel_getChannelOStream (HTChannel * ch);
2.1       frystyk   131: </PRE>
                    132: <PRE>
                    133: #endif /* HTCHANNL */
                    134: </PRE>
2.2       frystyk   135: <P>
                    136:   <HR>
2.1       frystyk   137: <ADDRESS>
2.9     ! frystyk   138:   @(#) $Id: HTChannl.html,v 2.8 1997/02/11 23:15:21 frystyk Exp $
2.1       frystyk   139: </ADDRESS>
2.2       frystyk   140: </BODY></HTML>

Webmaster