File:  [Public] / libwww / Library / src / HTChannl.html
Revision 2.12: download - view: text, annotated - select for diffs
Wed Jul 7 15:43:28 1999 UTC (24 years, 10 months ago) by frystyk
Branches: MAIN
CVS tags: repeat-requests, before_webdav, Release-5-4-0, Release-5-3-1, HEAD, Amaya-6-3, Amaya-6-1, Amaya-5-2, Amaya-4-3-2, Amaya-4-3-1, Amaya-4-3, Amaya-4-1-2, Amaya-4-1-0, Amaya-4-0-0, Amaya-3-2-1, Amaya-3-2, Amaya
Committing a set of patches that fixed the problem with listening on
sockets. The implementation is still client specific - it doesn't
handle generic incoming connections. However, it works for FTP and the
simple listen sample application. A future architecture should support
incoming connections as well as outgoing connections. For now, the
mget tool also works when downloading multiple files from an FTP
server using both PASV and PORT.

<HTML>
<HEAD>
  <TITLE>W3C Sample Code Library libwww Channel Interface</TITLE>
</HEAD>
<BODY>
<H1>
  The Channel Class
</H1>
<PRE>
/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
</PRE>
<P>
A channel contains information about sockets and their input and output streams.
A <CODE>channel</CODE> represents the front end for receiving data towards
the underlying transport. The definition of a channel describes how we are
to read the data coming in on a socket, for example. In other words - a channel
represents the first part of how to get handle incoming data in the Library:
<P>
<UL>
  <LI>
    Reading data on a channel
  <LI>
    Defining a target for incoming data
  <LI>
    Defining a protocol state machine that can handle the data
</UL>
<P>
This module is implemented by <A HREF="HTChannl.c">HTChannl.c</A>, and it
is a part of the <A HREF="http://www.w3.org/Library/"> W3C Sample Code
Library</A>.
<PRE>
#ifndef HTCHANNL_H
#define HTCHANNL_H

typedef struct _HTChannel HTChannel;

#include <A HREF="HTHost.html">"HTHost.h"</A>
#include <A HREF="HTIOStream.html">"HTIOStream.h"</A>
</PRE>
<H2>
  The Channel Object
</H2>
<P>
The channel object contains an input and an output stream for a particular
connection.
<H3>
  Creation and Deletion of Channel Objects
</H3>

Either the socket can be invalid (INVSOC) or the file descriptor can
be NULL but not both.

<PRE>
extern HTChannel * HTChannel_new (SOCKET sockfd, FILE * fp, BOOL active);
</PRE>
<H3>
  Deleting a Channel Object
</H3>
<PRE>
extern BOOL HTChannel_delete (HTChannel * channel, int status);
extern BOOL HTChannel_deleteAll (void);
extern BOOL HTChannel_safeDeleteAll (void);
</PRE>
<H3>
  Search for a Channel
</H3>
<P>
Look for a channel object if we for some reason should have lost it
<PRE>
extern HTChannel * HTChannel_find (SOCKET sockfd);
</PRE>
<H3>
  Get Transport Descriptor for Channel
</H3>
<P>
A transport descriptor can be either a ANSI C file descriptor or a BSD socket.
As it is difficult for the channel to know which one is used by a specific
transport, we leave this to the caller to figure out. This is probably not
the best way of doing it.
<PRE>
extern SOCKET HTChannel_socket	(HTChannel * channel);
extern BOOL HTChannel_setSocket	(HTChannel * channel, SOCKET socket);

extern FILE * HTChannel_file	(HTChannel * channel);
extern BOOL HTChannel_setFile   (HTChannel * channel, FILE * fp);
</PRE>
<H3>
  The Host Object
</H3>
<P>
The Channel object also keeps a link to the <A HREF="HTHost.html">host
object</A> so that we have a link to the persistent connection repository.
<PRE>extern BOOL HTChannel_setHost (HTChannel * ch, HTHost * host);
extern HTHost * HTChannel_host (HTChannel * ch);
</PRE>
<H3>
  Semaphores
</H3>
<P>
Adjust the semaphore on a channel. As many <A HREF="HTNet.html">Net objects
</A>can point to the same channel we need to keep count of them so that we
know if we can delete a channel or if it is still in use. We do this by having
a simple semaphore associated with each channel object
<PRE>
extern void HTChannel_upSemaphore   (HTChannel * channel);
extern void HTChannel_downSemaphore (HTChannel * channel);
extern void HTChannel_setSemaphore  (HTChannel * channel, int semaphore);
</PRE>
<H3>
  Create Input and Output Streams
</H3>
<P>
You create the input stream and bind it to the channel using the following
methods. Please read the description in the
<A HREF="HTIOStream.html">HTIOStream module</A> on the parameters
<EM>target</EM>, <EM>param</EM>, and <EM>mode</EM>. The input and output
stream are instances created by the <A HREF="HTTrans.html">Transport
object</A>. The Transport Object defines the creation methods for the inout
and output streams and the Channel object contains the actualy stream objects.
<PRE>
extern BOOL HTChannel_setInput (HTChannel * ch, HTInputStream * input);
extern HTInputStream * HTChannel_input (HTChannel * ch);
extern BOOL HTChannel_deleteInput (HTChannel * channel, int status);

extern BOOL HTChannel_setOutput (HTChannel * ch, HTOutputStream * output);
extern HTOutputStream * HTChannel_output (HTChannel * ch);
extern BOOL HTChannel_deleteOutput (HTChannel * channel, int status);

extern HTInputStream * HTChannel_getChannelIStream (HTChannel * ch);
extern HTOutputStream * HTChannel_getChannelOStream (HTChannel * ch);
</PRE>
<PRE>
#endif /* HTCHANNL */
</PRE>
<P>
  <HR>
<ADDRESS>
  @(#) $Id: HTChannl.html,v 2.12 1999/07/07 15:43:28 frystyk Exp $
</ADDRESS>
</BODY></HTML>

Webmaster