NNTP support library

Kari Pahula

This is a library for communicating with NNTP (network news transport protocol). It also aims to support more protocols. This library is very much work in progress.



1 General protocol interface

This library offers a framework for writing general request/response types of protocols.

1.1 Class Protocol.protocol

This class offers support for general protocol support. It has the following public methods.

init

init(host:  +HostV 
     port:  
+PortI 
     reopen:
+ReopenB <= false

Creates a new connection to host +HostV at port +PortI. If +ReopenB is true, the connection will be reopened if it's lost.

query

query(+QueriesRs)

Processes a list of queries.

request

request(+QueryR)

Processes a single query. Both of these methods take records with arguments passed in bound fields and replies passed in unbound ones. All replies have the field status in common with them. Common replies for this are atoms ok, for success, and closed, for a closed connection. A closed connection cannot be reopened; create a new connection if you want it.

close

close

Closes the connection.

bytesRead

bytesRead(AmountIs)

Returns the amount of bytes read by this connection so far. This is a list, with the tail bound when more bytes are read.

bytesWritten

bytesWritten(AmountIs)

Returns the amount of bytes written so far. Similar to bytesRead.

Protocol.protocol has also the following features.

host

Host address this protocol object is connected to.

port

Host port.

1.2 Creating protocols

Protocol.protocol can be subclassed. It has some additional methods for this use and requires a few methods.

sendText

sendText(vs:     +V 
         request:
+R<= nil)

Send the text message +V to the host. If +R is not nil, it is passed to the client's port.

parserMsg

parserMsg(+R)

Send message +R to the client from the parser.

parserMsg

parserMsg(+R)

Send message +R to the parser from the client.

parse

parse(+S)

This method has to be defined when implementing new protocols. +S is a list of characters received from the host. The parser typically communicates with the client with parserMsg. When the stream is closed, the parser has to call parserMsg(closed). This method will call itself recursively until the connection is closed.

Also, the method request has to be defined by the subclass.


Kari Pahula
Version 1.3.0 (20040430)