1 /* $Id: connection.h 6648 2004-01-25 20:07:11Z rra $
3 ** The public interface to the Connection class.
5 ** Written by James Brister <brister@vix.com>
7 ** The Connection class encapulates an NNTP protocol endpoint (either regular
8 ** or extended with the streaming protocol). Each Connection is owned by a
11 ** It manages the network connection (via an EndPoint) the the pumping of
12 ** articles to the remote host. It gets these articles from its Host object.
13 ** If the remote doesn't handle the streaming extension, then the Connection
14 ** will only manage one article at a time. If the remote handles the
15 ** extension, then the connection will queue up articles while sending the
16 ** CHECK and TAKETHIS commands.
18 ** If the network connection drops while the Connection object has articles
19 ** queued up, then it will hand them back to its Host object.
22 #if ! defined ( connection_h__ )
23 #define connection_h__
33 * Create a new Connection.
35 * HOST is the host object we're owned by.
36 * IDENT is an identifier to be added to syslog entries so we can tell
37 * what's happening on different connections to the same peer.
38 * IPNAME is the name (or ip address) of the remote)
39 * MAXTOUT is the maximum amount of time to wait for a response before
40 * considering the remote host dead.
41 * PORTNUM is the portnum to contact on the remote end.
42 * RESPTIMEOUT is the amount of time to wait for a response from a remote
43 * before considering the connection dead.
44 * CLOSEPERIOD is the number of seconds after connecting that the
45 * connections should be closed down and reinitialized (due to problems
46 * with old NNTP servers that hold history files open. Value of 0 means
49 Connection newConnection (Host host,
54 unsigned int respTimeout,
55 unsigned int closePeriod,
58 double lowPassFilter) ;
60 /* Causes the Connection to build the network connection. */
61 bool cxnConnect (Connection cxn) ;
63 /* puts the connection into the wait state (i.e. waits for an article
64 before initiating a connect). Can only be called right after
65 newConnection returns, or while the Connection is in the (internal)
67 void cxnWait (Connection cxn) ;
69 /* The Connection will disconnect as if cxnDisconnect were called and then
70 it automatically reconnects to the remote. */
71 void cxnFlush (Connection cxn) ;
73 /* The Connection sends remaining articles, then issues a QUIT and then
75 void cxnClose (Connection cxn) ;
77 /* The Connection drops all queueed articles, then issues a QUIT and then
79 void cxnTerminate (Connection cxn) ;
81 /* Blow away the connection gracelessly and immedately clean up */
82 void cxnNuke (Connection cxn) ;
84 /* Tells the Connection to take the article and handle its
85 transmission. If it can't (due to queue size or whatever), then the
86 function returns false. The connection assumes ownership of the
87 article if it accepts it (returns true). */
88 bool cxnTakeArticle (Connection cxn, Article art) ;
90 /* Tell the Connection to take the article (if it can) for later
91 processing. Assumes ownership of it if it takes it. */
92 bool cxnQueueArticle (Connection cxn, Article art) ;
94 /* generate a syslog message for the connections activity. Called by Host. */
95 void cxnLogStats (Connection cxn, bool final) ;
97 /* return the number of articles the connection can be given. This lets
98 the host shovel in as many as possible. May be zero. */
99 size_t cxnQueueSpace (Connection cxn) ;
101 /* adjust the mode no-CHECK filter values */
102 void cxnSetCheckThresholds (Connection cxn,
103 double lowFilter, double highFilter,
104 double lowPassFilter) ;
106 /* print some debugging info. */
107 void gPrintCxnInfo (FILE *fp, unsigned int indentAmt) ;
108 void printCxnInfo (Connection cxn, FILE *fp, unsigned int indentAmt) ;
110 /* config file load callback */
111 int cxnConfigLoadCbk (void *data) ;
113 /* check connection state is in cxnWaitingS, cxnConnectingS or cxnIdleS */
114 bool cxnCheckstate (Connection cxn) ;
116 #endif /* connection_h__ */