The Channel Class

/*
**	(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 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:

This module is implemented by HTChannl.c, and it is a part of the W3C Sample Code Library.

#ifndef HTCHANNL_H
#define HTCHANNL_H

typedef struct _HTChannel HTChannel;

#include "HTHost.h"
#include "HTIOStream.h"

The Channel Object

The channel object contains an input and an output stream for a particular connection.

Creation and Deletion of Channel Objects

Either the socket can be invalid (INVSOC) or the file descriptor can be NULL but not both.
extern HTChannel * HTChannel_new (SOCKET sockfd, FILE * fp, BOOL active);

Deleting a Channel Object

extern BOOL HTChannel_delete (HTChannel * channel, int status);
extern BOOL HTChannel_deleteAll (void);
extern BOOL HTChannel_safeDeleteAll (void);

Search for a Channel

Look for a channel object if we for some reason should have lost it

extern HTChannel * HTChannel_find (SOCKET sockfd);

Get Transport Descriptor for Channel

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.

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);

The Host Object

The Channel object also keeps a link to the host object so that we have a link to the persistent connection repository.

extern BOOL HTChannel_setHost (HTChannel * ch, HTHost * host);
extern HTHost * HTChannel_host (HTChannel * ch);

Semaphores

Adjust the semaphore on a channel. As many Net objects can point to the same channel we need to keep HTrequest object is the main entry point for an application to issue a request to the Library - all operations on a URL must use a Request object.

#include "HTReq.h"

Request Methods

This module defines the set of methods that you can perform on a request, for example GET, HEAD, PUT, POST, DELETE, etc.

#include "HTMethod.h"

The Anchor (URL) Class

An anchor represents a region of a hypertext document which is linked to another anchor in the same or a different document. Another name for anchors would be URLs as an anchor represents all we know about a URL - including where it points to and who points to it.

#include "HTAnchor.h"

The Link Class

A Link represents the link between anchor objects. By keeping the link as a object and not as part of the anchor we are capable of handling link semantics in a much more organized way. For example, we can then search for link types among all the link objects that we have created.

#include "HTLink.h"

Parsing URLs

This module contains code to parse URIs for the various components according to the URI syntax

#include "HTParse.h"

Escaping and Unescaping URLs

URLs are written only with the graphic printable characters of the US