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