(c)2001 by U.Keller, Email: visualbasic@uwekeller.de
This NNTP ActiveX control was designed to handle the whole transfer between a single client and a newsserver. It has been developed with visual basic 6 so its runtime library is required. The embedded commands are based on the standards RFC0850, RFC0977, RFC1036 and RFC2980. Although the NNTP control is written in visual basic, it has a very high performance. Most commands are working asyncronic. Please click on a topic below to read the description.
Methods | Properties | Events |
The connect command starts the connection to the newsserver. The host must be set to a valid hostname or IP-address. If required, a username and password must be set, too. After a connection is successfully created, the DoneConnect-Event is raised. If the connection fails, a DoneDisconnect-Event is fired with a return code.
Syntax: Object.Connect
The disconnect command disconnects from a current newsserver session. If the control state is in idle mode, the disconnect will be performed with a correct logout, otherwise the connection will be aborted. In any case the control will be completely disconnected and freed. To avoid abortion, check the control state previously.
Syntax: Object.Disconnect
This method retrieves the complete article from a newsserver. You have to set either the MsgId-Property or the MsgNo-Property before using the GetArticle-command. After the complete article has been retrieved, a DoneGetArticle-Event will be fired.
Syntax: Object.GetArticle
This method retrieves the body of an article from a newsserver. You have to set either the MsgId-Property or the MsgNo-Property before using the GetArticle-command. After the complete article has been retrieved, a DoneGetBody-Event will be fired.
Syntax: Object.GetBody
This method retrieves the header of an article from a newsserver. You may set the MsgId-Property or the MsgNo-Property before using the this command. After the complete article has been retrieved, a DoneGetHeader-Event is fired.
Syntax: Object.GetBody
This command retrieves a complete list of newsgroups from the newsserver. If you set the DateTime-Property, only newsgroups add after the given date will be received. After completion of this command, a DoneGetList-Event will be fired.
Syntax: Object.GetList
This command selects a new article at the newsserver. You may set the MsgId-Property or the MsgNo-Property before using the this command. After completion of this command, a DoneGetStat-Event will be fired. The properties MsgId and MsgNo will be updated.
Syntax: Object.GetStat
The GetXover-command retrieves a range of articles from the newsserver. You may set the range of articles by the FirstArticle-Property and LastArticle-Property before using the GetXover-command. After completion of this command, a DoneGetXover-Event will be fired.
Syntax: Object.GetXover
This command selects the previous article at the newsserver. After completion of this command, a DoneGotoLast-Event will be fired. The MsgId-Property and MsgNo-Property will be updated.
Syntax: Object.GotoLast
This command selects the next article at the newsserver. After completion of this command, a DoneGotoNext-Event will be fired. The MsgId-Property and MsgNo-Property will be updated.
Syntax: Object.GotoNext
This command sends a new article to a newsserver. The following properties must be set before using this command: Newsgroup, Author, Subject, Text. The always required message-id will be set automatically by the NNTP-control.
Syntax: Object.PostArticle
This functions returns the description of a given return code.
Syntax: Object.RcString(Rc As TNntpRc)
This method saves the current data to a file.
Normally you do not need this function because all data is available by their appropriate variables, but to increase the performance of your program you can directly save the data to a file without using the variables. For instance you can save a retrieved article body directly and much faster by this command instead of using a Print #1, Object.Text.
Syntax: Object.SaveData(Filename As String) As Boolean
If the data has been saved successfully, the function return true, otherwise false.
With this command you can enter a newsgroup. The newsgroup must be determined by the Newsgroup-Property. Of course you have to be connected to a newsserver. After the newsgroup is selected, a DoneSelectGroup-Event will be fired. The following properties will be updated: FirstArticle, LastArticle, ArticleCount and MsgNo.
Syntax: Object.SelectGroup
This property returns the estimated number of articles in the selected newsgroup and will be set right after the newsgroup has been selected.
Syntax: Object.ArticleCount() As Long
This property returns or sets the name and email address of the author of the current article. An example in standard format is: "john@provider.com (John Miller)"
Syntax: Object.Author() As String
This property returns the transmission speed of the last command. The unit is bytes per second.
Syntax: Object.BPS() As Single
The bytes property returns the size of the current article which has been set by the DataIndex-Property.
Syntax: Object.Bytes() As Single
After retrieving a list of data e.g. by the GetList-Method or GetXover-Method, this property returns the number of received lines.
Syntax: Object.DataCount() As Long
After receiving data with the GetList-Method or GetXover-Method, the received data is stored in the internal memory of the control. It can be accessed by setting this property to a value between 1 and DataCount-Property.
Syntax: Object.DataIndex() As Long
Depending on the content the following properties will be changed:
After GetList-Method:
Newsgroup, FirstArticle, LastArticle, Posting
After GetXover-Method:
MsgId, MsgNo, Subject, Date, Author, References, XRef, Bytes, Lines
This property returns the size of the current data, e.g. the size of the received list of newsgroups or the size of the retrieved article.
Syntax: Object.DataSize() As Long
After retrieving a list of data, e.g. newsgroups by the GetList-method, the Data property contains an array of all received lines. The Index must be a value between 1 and DataCount.
Syntax: Object.DataText() As String
After receiving article headers with the GetXover-Method and setting the DataIndex-Property the DateTime-Property returns the issue of the article.
Before receiving a list of newsgroups with the GetList-Method, you can set this property to receive only groups add since the specific date.
Syntax: Object.DateTime() As Date
Returns or sets the debugger mode. If it is set to true, a Debugger-Event is fired each time a data line has been completely received.
Syntax: Object.Debugger() As Boolean
This property returns or sets the number of the first article in a newsgroup. It will be set automatically by the SelectGroup-method, but may be overwritten afterwards, e.g. to retrieve a range of article headers by the GetXover-method.
Syntax: Object.FirstArticle() As Long
This property returns or sets the name or IP-address of the newsserver. This must be set before using the Connect-method.
Syntax: Object.Host() As String
After a connection has been performed successfully, the Hostinfo-property returns the welcome message of the newsserver.
Syntax: Object.Hostinfo() As String
This property returns or sets the number of the last article in a newsgroup. It will be set automatically by the SelectGroup-method, but may be overwritten afterwards, e.g. to retrieve a range of article headers by the GetXover-method.
Syntax: Object.LastArticle() As Long
The lines property returns the size of the current article which has been set by the DataIndex-Property.
Syntax: Object.Lines() as Long
After receiving an article body, the message property returns the message text only neither with headers nor binaries.
Syntax: Object.Message() as String
This property returns or sets the message-ID of the current article. This property have to be set before using the PostArticle-method. If you want to retrieve an articles header or body, you have to set either the MsgNo-property or the MsgId-property.
Syntax: Object.MsgId() As String
This property returns or sets the message-number of the current article. If you want to retrieve an articles header or body, you have to set either the MsgNo-property or the MsgId-property.
Syntax: Object.MsgNo() As Long
This property returns or sets the newsgroup name. This property have to be set before using the SelectGroup-method.
Syntax: Object.Newsgroup() As String
Important: The Newsgroup-property will be cleared after a login and logout. If you want to enter a newsgroup, you have to set the newsgroup-property after a successful login to a newsserver.
The newsreader property returns or sets the name of the newsreader program. If you program your own application, you can enter the name here. It will be attached to each posted article in the X-Newsreader header field.
Syntax: Object.Newsreader() As String
Sometimes a newsserver requires a authorized login by a username and password. This property returns or sets the password. This property must be set before using the Connect-method.
Syntax: Object.Newsgroup() As String
The posting property will be set after a login to a newserver and tells whether posting on that server is allowed or not. This property will also be set by changing the DataIndex-Property in case that the current received data are newsgroups. It indicates whether it is possible to post to the selected newsgroup.
Syntax: Object.Posting() As Boolean
This property returns the number of received bytes since the last server login. You can also asign a new value, but it makes only sense to reset the value by setting the property to zero.
Syntax: Object.Received() As Long
This property returns or sets the references to other articles. You may set this property if you want to reply to an article. The reference is the message-id of the other article.
Syntax: Object.References() As String
This property returns or sets the delay time in seconds until the control sends a help command to the newsserver. When the control is connected to a newsserver and in idle mode, the help command will be send after the refresh-time has expired. The only sense to do this is to keep a connection alive, because some newsservers disconnect you if after a specific idle time. If you set the refresh-property to 0, this function is off.
Syntax: Object.Refresh() As Integer
This property returns the size of the current data, which can be a list of newsgroups, an article header or body, or anything else.
Syntax: Object.Size() As Long
Note: The Bytes-Property returns the number of bytes extracted from an article header received by th GetXover-Method.
This is a very important property. It returns the current control state. You can use this to avoid errors during runtime of your program.
Syntax: Object.State() As TNntpState
Const | Value | Description |
NNTP_STAT_DISCONNECTED | 0 | The control is not connected to a newsserver. |
NNTP_STAT_DISCONNECTING | 1 | The control is executing a disconnect. |
NNTP_STAT_CONNECTED | 2 | The control is connected to a newsserver, but in idle mode (nothing to do). |
NNTP_STAT_CONNECTING | 3 | The control is executing a connect. |
NNTP_STAT_SELECTING | 4 | The control selects a newsgroup, but has not completed yet. |
NNTP_STAT_GETLIST | 5 | The control gets a list of newsgroups, but has not finished. |
NNTP_STAT_GETXOVER | 6 | The control gets a range of article headers, but is still busy. |
NNTP_STAT_GETSTAT | 7 | The control gets the state of an article. |
NNTP_STAT_GETARTICLE | 8 | The control receives an article. |
NNTP_STAT_GETHEADER | 9 | The control receives a header of an article. |
NNTP_STAT_GETBODY | 10 | The control receives a body of an article. |
NNTP_STAT_GOTOLAST | 11 | The control goes to the previous article. |
NNTP_STAT_GOTONEXT | 12 | The control goes to the next article. |
NNTP_STAT_POSTING | 13 | The control is posting an article, but has not finished yet. |
This property returns or sets the subject of the article. You must either set this property before using the PostArticle-method. After the GetXover-Method you have to set the current index by the DataIndex-Property.
Syntax: Object.Subject() As String
The text property returns or sets the complete article data which has been received or got to be send.
Syntax: Object.Text() As String
This property returns or sets the delay time in seconds until the control reports a timeout. Every time the control is busy but the last receive of data is longer ago then the specified time, the appropriate Done-Event is fired with a timeout return code. If you set the timeout-property to 0, the function is off.
Syntax: Object.Timeout() As Integer
Returns or sets the username. Some newsservers require an authorized login. In that case, the username and password have to be set before doing the Connect-method.
Syntax: Object.Username() As String
This property returns or sets the XRef data from an article header received by the GetXover-Method. Before you have to set the current index by the DataIndex-Property.
Syntax: Object.Xref() As String
If the Debugger-property is set to true, each time a line is completely received it will be handed over to this event.
Syntax: Object_Debugger(Text As String)
After a connection to a newsserver has been done, the DoneConnect-event will be fired, even if the connection failed. The return code gives you further information about the connection state.
Syntax: Object_DoneConnect(Rc As TNntpRc)
If the connection is successful, the following properties will be changed:
After a disconnect from a newsserver has been done, the DoneDisconnect-event will be fired. The return code gives you further information about the connection state.
Syntax: Object_DoneDisconnect(Rc As TNntpRc)
If a disconnect is not possible, e.g. because another command is still executing, the execution will be stopped immediately and the connection will be aborted. In that case you will not be logged out from the newsserver.
The return code of a normal logout is NNTP_RC_CLOSING.
When an article has been received, the DoneGetArticle-event will be fired, even if the transmission failed. The return code gives you further information about the transmission.
Syntax: Object_DoneGetArticle(Rc As TNntpRc)
If the article has been received successfully, the returncode is NNTP_RC_ARTICLE.
When an articles body has been received, the DoneGetBody-event will be fired, even if the transmission failed. The return code gives you further information about the transmission.
Syntax: Object_DoneGetBody(Rc As TNntpRc)
If the body has been received successfully, the returncode is NNTP_RC_BODY.
When an articles header has been received, the DoneGetHeader-event will be fired, even if the transmission failed. The return code gives you further information about the transmission.
Syntax: Object_DoneGetHeader(Rc As TNntpRc)
If the header has been received successfully, the returncode is NNTP_RC_HEADER.
When a list of newsgroups has been received, the DoneGetList-event will be fired, even if the transmission failed. The return code gives you further information about the transmission.
Syntax: Object_DoneGetList(Rc As TNntpRc)
If the newsgroups have been received successfully, the returncode is NNTP_RC_LIST. You can gain access to the list of data with the DataIndex-Property.
After a GetStat-method has been performed, the DoneGetStat-event will be fired, even if the transmission failed. The return code gives you further information about the transmission.
Syntax: Object_DoneGetStat(Rc As TNntpRc)
If the GetStat-method has been performed successfully, the return code is NNTP_RC_STAT.
When a range of article headers have been received, the DoneGetXover-event will be fired, even if the transmission failed. The return code gives you further information about the transmission.
Syntax: Object_DoneGetXover(Rc As TNntpRc)
If the headers have been received successfully, the return code is NNTP_RC_DATAFOLLOWS. You can gain access to the list of data with the DataIndex-Property.
After the GotoLast-method has been performed, the DoneGotpLast-event will be fired, even if the access failed. The return code gives you further information about the transmission.
Syntax: Object_DoneGotoLast(Rc As TNntpRc)
If the previous article has been accessed succesfully, the return code is NNTP_RC_STAT.
After the GotoNext-method has been performed, the DoneGotoLast-event will be fired, even if the access failed. The return code gives you further information about the transmission.
Syntax: Object_DoneGotoNext(Rc As TNntpRc)
If the next article has been accessed succesfully, the return code is NNTP_RC_STAT.
After completion of an article post, the DonePost-event will be fired, even if the transmission failed. The return code gives you further information about the transmission.
Syntax: Object_DonePost(Rc As TNntpRc)
If the next article has been posted succesfully, the return code is NNTP_RC_POSTEDOK.
After a new newsgroup has been selected, the DoneSelectGroup-event will be fired, even if the selection failed. The return code gives you further information about the transmission.
Syntax: Object_DoneSelectGroup(Rc As TNntpRc)
If the newsgroup has been succesfully selected, the return code is NNTP_RC_GROUPSELECTED. The following properties will be changed:
Each time when data arrives, the Receive-event is fired. The number of received lines will be given by the Count-variable.
Syntax: Object_Receive(Count As Long)
Constant | Value | Message |
NNTP_RC_NONE | 0 | "" |
NNTP_RC_NOTCONNECTED | 1 | Not connected |
NNTP_RC_HOSTNOTFOUND | 2 | Host not found |
NNTP_RC_BUSY | 3 | Busy |
NNTP_RC_SOCKERR | 4 | Socket error |
NNTP_RC_CANCELED | 5 | Canceled |
NNTP_RC_TIMEOUT | 6 | Timeout |
NNTP_RC_POSTING | 200 | Posting allowed |
NNTP_RC_NOPOSTING | 201 | No posting allowed |
NNTP_RC_CLOSING | 205 | Connection closed |
NNTP_RC_GROUPSELECTED | 211 | Newsgroup selected |
NNTP_RC_LIST | 215 | List follows |
NNTP_RC_ARTICLE | 220 | Article follows |
NNTP_RC_HEAD | 221 | Header follows |
NNTP_RC_BODY | 222 | Body follows |
NNTP_RC_STAT | 223 | Statistic follows |
NNTP_RC_DATAFOLLOWS | 224 | Data follows |
NNTP_RC_NEWARTICLES | 230 | New articles follow |
NNTP_RC_NEWGROUPS | 231 | New newsgroup follow |
NNTP_RC_TRANSFERRED | 235 | Transferred |
NNTP_RC_POSTEDOK | 240 | Posted |
NNTP_RC_AUTHENTICATIONACCEPTED | 281 | Authentication accepted |
NNTP_RC_SENDARTICLETRANSFERRED | 335 | Send article to be transferred |
NNTP_RC_SENDARTICLE | 340 | Send article to be posted |
NNTP_RC_MOREAUTHENTICATIONREQUIRED | 381 | More authentication required |
NNTP_RC_SERVICEDISCONTINUED | 400 | Service discontinued |
NNTP_RC_NOSUCHNEWSGROUP | 411 | No such newsgroup |
NNTP_RC_NOTINANEWSGROUP | 412 | Not in a newsgroup |
NNTP_RC_NOARTICLESELECTED | 420 | No article selected |
NNTP_RC_NONEXTARTICLE | 421 | No next article |
NNTP_RC_NOLASTARTICLE | 422 | No last article |
NNTP_RC_BADARTICLENUMBER | 423 | Bad article number |
NNTP_RC_ARTICLENOTFOUND | 430 | Article not found |
NNTP_RC_DONTSEND | 435 | Do not send |
NNTP_RC_TRANSFERFAILED | 436 | Transfer failed |
NNTP_RC_ARTICLEREJECTED | 437 | Article rejected |
NNTP_RC_POSTINGNOTALLOWD | 440 | Posting permitted |
NNTP_RC_POSTINGFAILED | 441 | Posting failed |
NNTP_RC_AUTHENTICATIONREQUIRED | 480 | Authentication required |
NNTP_RC_NOSUCHCOMMAND | 500 | No such command |
NNTP_RC_SYNTAXERROR | 501 | Syntax error |
NNTP_RC_ACCESSRESTRICTED | 502 | Access restricted |
NNTP_RC_PROGRAMNOTFAULT | 503 | Program not fault |