File:  [Public] / libwww / Library / src / HTHstMan.html
Revision 2.18: download - view: text, annotated - select for diffs
Wed Jul 7 15:43:28 1999 UTC (24 years, 11 months ago) by frystyk
Branches: MAIN
CVS tags: HEAD, Amaya-3-2-1, Amaya-3-2
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 Private Hst Definition</TITLE>
</HEAD>
<BODY>
<H1>
  Private Host Definition
</H1>
<PRE>
/*
**	(c) COPYRIGHT MIT 1995.
**	Please first read the full copyright statement in the file COPYRIGH.
*/
</PRE>
<P>
This is the private definition of the Host Class. Please look in the public
<A HREF="HTHost.html">Host Class</A> for more documentation
<P>
This module is implemented by <A HREF="HTHost.c">HTHost.c</A>, and it is
a part of the <A HREF="http://www.w3.org/Library/">W3C Sample Code Library</A>.
<PRE>
#ifndef HTHSTMAN_H
#define HTHSTMAN_H
#include "HTHost.h"
#include "HTDNS.h"
#include "HTEvent.h"
#include "HTProt.h"

#define PIPE_BUFFER_SIZE	8192
</PRE>
<P>
The <CODE>HTHost</CODE> object is the core of the request queue management.
This object contains information about the socket descriptor, the input read
buffer etc. required to identify and service a request.
<PRE>
typedef enum _TCPState {
    TCP_DNS_ERROR	= -3,
    TCP_ERROR		= -2,
    TCP_CONNECTED	= -1,
    TCP_BEGIN		= 0,
    TCP_CHANNEL,
    TCP_DNS,
    TCP_NEED_SOCKET,
    TCP_NEED_BIND,
    TCP_NEED_LISTEN,
    TCP_NEED_CONNECT,
    TCP_IN_USE
} TCPState;

struct _HTHost {
    int                 hash;

    /* Information about the otherend */
    char *  		hostname;	     /* name of host + optional port */
    u_short		u_port;
    time_t		ntime;				    /* Creation time */
    char *		type;				        /* Peer type */
    int 		version;			     /* Peer version */
    HTMethod		methods;	       	/* Public methods (bit-flag) */
    char *		server;				      /* Server name */
    char *		user_agent;			       /* User Agent */
    char *		range_units;			       	      /* ??? */

    /* When does this entry expire? */
    time_t		expires;	  /* Persistent channel expires time */
    int			reqsPerConnection;	  /* from Keep-Alive: header */
    int			reqsMade;		 /* updated as they are sent */

    /* Queuing and connection modes */
    HTList *		pipeline;		 /* Pipe line of net objects */
    HTList *		pending;	      /* List of pending Net objects */
    HTNet *             doit;               /* Transfer from pending to pipe */ 
    HTNet *             lock;             /* This is a kludge! */
    HTNet *		listening;	 /* Master for accepting connections */
    BOOL		persistent;
    HTTransportMode	mode;	      			   /* Supported mode */
    HTTimer *           timer;         /* Timer for handling idle connection */
    BOOL                do_recover;         /* If we are supposed to recover */
    int                 recovered;        /* How many times had we recovered */
    BOOL                close_notification;        /* Got a hint about close */
    BOOL                broken_pipe;

    /* Support for transports */
    HTChannel *		channel;			     /* data channel */

    /* Connection dependent stuff */
    HTdns *		dns;			       /* Link to DNS object */
    TCPState		tcpstate;		      /* State in connection */
    SockA 		sock_addr;	     /* SockA is defined in wwwsys.h */
    int			retry;		     /* Counting attempts to connect */
    int 		home;			 /* Current home if multiple */
    ms_t		connecttime;	   /* Time in ms on multihomed hosts */

    /* Event Management */
    HTEvent *		events[HTEvent_TYPES];/* reading and writing may differ */
    HTEventType	        registeredFor;	  /* Which actions are we blocked on */
    size_t		remainingRead;	 /* Tells HostEvent to call next net */

    /* User specific stuff */
    ms_t                delay;                          /* Write delay in ms */
    void *		context;		/* Protocol Specific context */
    int			forceWriteFlush;
};

#define HTHost_bytesRead(me)		((me) ? (me)-&gt;bytes_read : -1)
#define HTHost_bytesWritten(me)		((me) ? (me)-&gt;bytes_written : -1)

#define HTHost_setBytesRead(me,l)	((me) ? (me-&gt;bytes_read=(l)) : -1)
#define HTHost_setBytesWritten(me,l)	((me) ? (me-&gt;bytes_written=(l)) :-1)
#define HTHost_setDNS (host, dns)	((me) ? (me-&gt;dns=(dns)) :-1)
</PRE>
<PRE>
#endif /* HTHSTMAN_H */
</PRE>
<P>
  <HR>
<ADDRESS>
  @(#) $Id: HTHstMan.html,v 2.18 1999/07/07 15:43:28 frystyk Exp $
</ADDRESS>
</BODY></HTML>

Webmaster