File:  [Public] / libwww / Library / src / HTSocket.html
Revision 2.10: download - view: text, annotated - select for diffs
Fri Oct 27 19:12:14 1995 UTC (28 years, 7 months ago) by frystyk
Branches: MAIN
CVS tags: v4/0pre5, v4/0pre4, HEAD
First version of a new News module

<HTML>
<HEAD>
<TITLE>Socket I/O Manager</TITLE>
<!-- Changed by: Henrik Frystyk Nielsen, 22-Oct-1995 -->
<NEXTID N="z18">
</HEAD>
<BODY>

<H1>Manages Read and Write to and from the Network</H1>

<PRE>
/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
</PRE>

This module defines the read and write functions to and from the
network. As we are having reentrant function and a smarter network I/O
this will get very small :-) <P>

This module is implemented by <A HREF="HTSocket.c">HTSocket.c</A>, and
it is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C
Reference Library</A>.

<PRE>
#ifndef HTSOCKET_H
#define HTSOCKET_H

#include <A HREF="tcp.html">"tcp.h"</A>
#include <A HREF="HTReq.html">"HTReq.h"</A>
#include <A HREF="HTStream.html">"HTStream.h"</A>
#include <A HREF="HTAnchor.html">"HTAnchor.h"</A>
</PRE>

<H2>Create an Input Buffer</H2>

This function allocates a input buffer and binds it to the socket
descriptor given as parameter. The size of the buffer,
<CODE>INPUT_BUFFER_SIZE</CODE>, is a compromise between speed and
memory. Here it is chosen as the default TCP High Water Mark
(sb_hiwat) for receiving data.

<PRE>

#define INPUT_BUFFER_SIZE 8192

typedef struct _HTInputSocket HTInputSocket;

extern HTInputSocket* HTInputSocket_new (SOCKFD file_number);
</PRE>

<H2>Free an Input Buffer</H2>

<PRE>
extern void HTInputSocket_free (HTInputSocket * isoc);
</PRE>

<A NAME="Read"><H2>Read Data from a Socket</H2></A>

This function has replaced many other functions for doing read from a
socket. It automatically converts from ASCII if we are on a NON-ASCII
machine. This assumes that we do <B>not</B> use this function to read
a local file on a NON-ASCII machine. The following type definition is
to make life easier when having a state machine looking for a
<CODE>&lt;CRLF&gt;</CODE> sequence.

<PRE>
typedef enum _HTSocketEOL {
    EOL_ERR = -1,
    EOL_BEGIN = 0,
    EOL_FCR,
    EOL_FLF,
    EOL_DOT,
    EOL_SCR,
    EOL_SLF
} HTSocketEOL;

extern int HTSocketRead	(HTRequest * request, HTNet * net);
</PRE>

<H2>Read from an ANSI file Descriptor</H2>

This function has replaced the HTParseFile() and HTFileCopy functions
for read from an ANSI file descriptor.

<PRE>
extern int HTFileRead	(HTRequest * request, HTNet * net, FILE * fp);
</PRE>

<HR>

<B><IMG ALIGN=middle
SRC="http://www.w3.org/pub/WWW/Icons/32x32/caution.gif"> DON'T USE
THESE FUNCTIONS - THEY ARE NOT REENTRANT. </B>

<HR>

<PRE>
extern int HTParseSocket PARAMS((HTFormat format, SOCKFD file_number, HTRequest * rq));
extern int HTInputSocket_getCharacter PARAMS((HTInputSocket* isoc));
extern char * HTInputSocket_getBlock PARAMS((HTInputSocket * isoc, int * len));
extern char * HTInputSocket_getLine PARAMS((HTInputSocket * isoc));
extern char * HTInputSocket_getUnfoldedLine PARAMS((HTInputSocket * isoc));
extern char * HTInputSocket_getStatusLine PARAMS((HTInputSocket * isoc));
</PRE>

<PRE>
#endif
</PRE>

End of declaration module

</BODY>
</HTML>

Webmaster