TNewsServer / TNewsInstance

Sources: source/classes/tnewssrv.prg, source/classes/tnewsins.prg

TNewsServer standalone | TNewsInstance helper

TNewsServer implements an NNTP (Network News Transfer Protocol) news server on port 119. It is built on TSocket and uses DBF/CDX files to store newsgroups and articles. TNewsInstance handles each connected client session, parsing NNTP commands and serving article data.

TNewsServer

Key DATA Members

DATATypeDescription
oTimerObjectTimer for periodic client task processing
oSocketObjectListener socket bound to port 119
aInstancesArrayArray of TNewsInstance objects for active clients
cDefPathCharacterDefault data directory for DBF/CDX files
lDebugLogicalEnable debug logging to cLogFile

Methods

MethodDescription
New( oWnd, cPath )Create server; creates Groups.dbf and indexes in cPath
Activate()Start listening on port 119 for incoming connections
End()Stop timer, close socket, and terminate all client instances

TNewsInstance

Key DATA Members

DATATypeDescription
oSocketObjectClient socket for this NNTP session
oServerObjectParent TNewsServer reference
cGroupCharacterCurrently selected newsgroup name
lPostAllowLogicalWhether posting is allowed

NNTP Commands Implemented

MethodNNTP CommandDescription
Article()ARTICLERetrieve article head and/or body
Head()HEADRetrieve article header only
Body()BODYRetrieve article body only
Group()GROUPSelect a newsgroup
List()LISTList available newsgroups
ListGroup()LISTGROUPList article numbers in current group
Post()POSTBegin posting a new article
Quit()QUITEnd the NNTP session
NewGroups()NEWGROUPSList groups created since a date/time
XOver()XOVEROverview of articles (subject, author, date, etc.)
Stat()STATCheck if article exists without retrieving it

Example: Start News Server

#include "FiveWin.ch"

function Main()

   local oWnd, oServer

   DEFINE WINDOW oWnd TITLE "NNTP News Server" SIZE 600, 400

   oServer := TNewsServer():New( oWnd, "c:\newsserver\data" )
   oServer:Activate()

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also