Manages Read and Write to and from the Network
/*
** (c) COPYRIGHT MIT 1995.
** Please first read the full copyright statement in the file COPYRIGH.
*/
A channel contains information about sockets and their input and
output streams. A channel represents the front end for
receiving data. The definition of a channel describes how we are to
read the data coming in on a socket, for example. A channel represents
the first part of how to get handle incoming data in the Library:
- Reading data on a channel
- Defining a target for incoming data
- Defining a protocol state machine that can handle the data
This module is implemented by HTChannl.c, and
it is a part of the W3C
Reference Library.
#ifndef HTCHANNL_H
#define HTCHANNL_H
typedef enum _HTChannelMode {
HT_CH_SINGLE = 0, /* One single request at a time */
HT_CH_BATCH = 1, /* Use batch requests */
HT_CH_INTERLEAVED = 2 /* Can we interleave requests? */
} HTChannelMode;
typedef struct _HTChannel HTChannel;
#include "HTTrans.h"
#include "HTReq.h"
#include "HTNet.h"
#include "HTIOStream.h"
The HTChannel Object
A channel can be in a certain mode which determines how
it behaves. The set of modes is defined as:
Creating a Channel Object
The following methods can be used to instantiate objects of a
particular channel mode:
extern HTChannel * HTChannel_new (HTNet * net, BOOL active);
Deleting a Channel Object
extern BOOL HTChannel_delete (HTChannel * channel);
extern BOOL HTCannel_deleteAll (void);
Control the Channel Mode
Set and get the mode of a channel. A channel may change mode in the
middle of a connection. We also return whether the channel is active
or passive.
extern HTChannelMode HTChannel_mode (HTChannel * channel, BOOL * active);
extern BOOL HTChannel_setMode (HTChannel * channel, HTChannelMode mode);
Search for a Channel
Look for a channel object if we for some reason should have lost it
extern HTChannel * HTChannel_find (SOCKET sockfd);
Is Channel Idle?
Check whether a channel is idle meaning if it is ready for a new
request which depends on the mode of the channel. If the channel is
idle, i.e. ready for use then return YES else NO.
extern BOOL HTChannel_idle (HTChannel * channel);
Get Socket for a Channel
extern SOCKET HTChannel_socket (HTChannel * channel);
Semaphores
Adjust the semaphore on a channel.
extern void HTChannel_upSemaphore (HTChannel * channel);
extern void HTChannel_downSemaphore (HTChannel * channel);
Create Input and Output Streams
You create the input stream and bind it to the channel using the
following methods. Please read the description in the HTIOStream module on the parameters
target, param, and mode. Both methods
return YES if OK, else NO.
extern BOOL HTChannel_setInput (HTChannel * ch,
HTInputStream * input, HTChannelMode mode);
extern BOOL HTChannel_setOutput (HTChannel * ch,
HTOutputStream * output, HTChannelMode mode);
extern HTInputStream * HTChannel_input (HTChannel * ch);
extern HTOutputStream * HTChannel_output (HTChannel * ch);
#endif /* HTCHANNL */
@(#) $Id: HTChannl.html,v 2.1 1996/04/12 17:46:13 frystyk Exp $