Annotation of libwww/Library/src/HTChannl.html, revision 2.11
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:
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.11 ! kahan 65: extern BOOL HTChannel_safeDeleteAll (void);
2.1 frystyk 66: </PRE>
2.2 frystyk 67: <H3>
68: Search for a Channel
69: </H3>
70: <P>
2.1 frystyk 71: Look for a channel object if we for some reason should have lost it
72: <PRE>
73: extern HTChannel * HTChannel_find (SOCKET sockfd);
74: </PRE>
2.2 frystyk 75: <H3>
76: Get Transport Descriptor for Channel
77: </H3>
78: <P>
79: A transport descriptor can be either a ANSI C file descriptor or a BSD socket.
80: As it is difficult for the channel to know which one is used by a specific
81: transport, we leave this to the caller to figure out. This is probably not
82: the best way of doing it.
2.7 frystyk 83: <PRE>
84: extern SOCKET HTChannel_socket (HTChannel * channel);
2.8 frystyk 85: extern BOOL HTChannel_setSocket (HTChannel * channel, SOCKET socket);
86:
2.2 frystyk 87: extern FILE * HTChannel_file (HTChannel * channel);
2.8 frystyk 88: extern BOOL HTChannel_setFile (HTChannel * channel, FILE * fp);
2.6 frystyk 89: </PRE>
90: <H3>
91: The Host Object
92: </H3>
93: <P>
94: The Channel object also keeps a link to the <A HREF="HTHost.html">host
95: object</A> so that we have a link to the persistent connection repository.
96: <PRE>extern BOOL HTChannel_setHost (HTChannel * ch, HTHost * host);
97: extern HTHost * HTChannel_host (HTChannel * ch);
2.2 frystyk 98: </PRE>
99: <H3>
100: Semaphores
101: </H3>
102: <P>
103: Adjust the semaphore on a channel. As many <A HREF="HTNet.html">Net objects
104: </A>can point to the same channel we need to keep count of them so that we
105: know if we can delete a channel or if it is still in use. We do this by having
106: a simple semaphore associated with each channel object
2.1 frystyk 107: <PRE>
2.4 frystyk 108: extern void HTChannel_upSemaphore (HTChannel * channel);
2.1 frystyk 109: extern void HTChannel_downSemaphore (HTChannel * channel);
2.4 frystyk 110: extern void HTChannel_setSemaphore (HTChannel * channel, int semaphore);
2.1 frystyk 111: </PRE>
2.2 frystyk 112: <H3>
113: Create Input and Output Streams
114: </H3>
115: <P>
116: You create the input stream and bind it to the channel using the following
117: methods. Please read the description in the
118: <A HREF="HTIOStream.html">HTIOStream module</A> on the parameters
119: <EM>target</EM>, <EM>param</EM>, and <EM>mode</EM>. The input and output
120: stream are instances created by the <A HREF="HTTrans.html">Transport
121: object</A>. The Transport Object defines the creation methods for the inout
122: and output streams and the Channel object contains the actualy stream objects.
2.1 frystyk 123: <PRE>
2.6 frystyk 124: extern BOOL HTChannel_setInput (HTChannel * ch, HTInputStream * input);
2.2 frystyk 125: extern HTInputStream * HTChannel_input (HTChannel * ch);
126:
2.6 frystyk 127: extern BOOL HTChannel_setOutput (HTChannel * ch, HTOutputStream * output);
2.1 frystyk 128: extern HTOutputStream * HTChannel_output (HTChannel * ch);
2.7 frystyk 129:
130: extern HTInputStream * HTChannel_getChannelIStream (HTChannel * ch);
131: extern HTOutputStream * HTChannel_getChannelOStream (HTChannel * ch);
2.1 frystyk 132: </PRE>
133: <PRE>
134: #endif /* HTCHANNL */
135: </PRE>
2.2 frystyk 136: <P>
137: <HR>
2.1 frystyk 138: <ADDRESS>
2.11 ! kahan 139: @(#) $Id: HTChannl.html,v 2.10 1998/05/14 02:10:20 frystyk Exp $
2.1 frystyk 140: </ADDRESS>
2.2 frystyk 141: </BODY></HTML>
Webmaster