On this page:
16.1 Connection and Operations
communicator
connect-to-server
disconnect-from-server
open-news-group
authenticate-user
head-of-message
body-of-message
newnews-since
generic-message-command
make-desired-header
extract-desired-headers
16.2 Exceptions
nntp
unexpected-response
bad-status-line
premature-close
bad-newsgroup-line
non-existent-group
article-not-in-group
no-group-selected
article-not-found
authentication-rejected
16.3 NNTP Unit
nntp@
16.4 NNTP Signature
nntp^

16 NNTP: Newsgroup Protocol🔗ℹ

 (require net/nntp) package: net-lib
The net/nntp module provides tools to access Usenet group via NNTP [RFC977].

16.1 Connection and Operations🔗ℹ

struct

(struct communicator (sender receiver server port)
    #:extra-constructor-name make-communicator)
  sender : output-port?
  receiver : input-port?
  server : string?
  port : (integer-in 0 65535)
Once a connection to a Usenet server has been established, its state is stored in a communicator, and other procedures take communicators as an argument.

procedure

(connect-to-server server [port-number])  communicator?

  server : string?
  port-number : (integer-in 0 65535) = 119
Connects to server at port-number.

procedure

(disconnect-from-server communicator)  void?

  communicator : communicator?
Disconnects an NNTP communicator.

procedure

(open-news-group communicator newsgroup)

  
exact-nonnegative-integer?
exact-nonnegative-integer?
exact-nonnegative-integer?
  communicator : communicator?
  newsgroup : string?
Selects the newsgroup of an NNTP connection. The returned values are the total number of articles in the group, the first available article, and the last available article.

procedure

(authenticate-user communicator    
  username    
  password)  void?
  communicator : communicator?
  username : string?
  password : string?
Tries to authenticate a user with the original authinfo command (uses cleartext). The password argument is ignored if the server does not ask for it.

procedure

(head-of-message communicator    
  message-index)  (listof string?)
  communicator : communicator?
  message-index : exact-nonnegative-integer?
Given a message number, returns its header lines.

procedure

(body-of-message communicator    
  message-index)  (listof string?)
  communicator : communicator?
  message-index : exact-nonnegative-integer?
Given a message number, returns the body of the message.

procedure

(newnews-since communicator message-index)  (listof string?)

  communicator : communicator?
  message-index : exact-nonnegative-integer?
Implements the NEWNEWS command (often disabled on servers).

procedure

((generic-message-command command    
  ok-code)    
  communicator    
  message-index)  (listof string?)
  command : string?
  ok-code : exact-integer?
  communicator : communicator?
  message-index : exact-nonnegative-integer?
Useful primitive for implementing head-of-message, body-of-message and other similar commands.

procedure

(make-desired-header tag-string)  regexp?

  tag-string : string?
Takes a header field’s tag and returns a regexp to match the field

procedure

(extract-desired-headers header desireds)  (listof string?)

  header : (listof string?)
  desireds : (listof regexp?)
Given a list of header lines and of desired regexps, returns the header lines that match any of the desireds.

16.2 Exceptions🔗ℹ

struct

(struct nntp exn ()
    #:extra-constructor-name make-nntp)
The supertype of all NNTP exceptions.

struct

(struct unexpected-response nntp (code text)
    #:extra-constructor-name make-unexpected-response)
  code : exact-integer?
  text : string?
Raised whenever an unexpected response code is received. The text field holds the response text sent by the server.

struct

(struct bad-status-line nntp (line)
    #:extra-constructor-name make-bad-status-line)
  line : string?
Raised for mal-formed status lines.

struct

(struct premature-close nntp (communicator)
    #:extra-constructor-name make-premature-close)
  communicator : communicator?
Raised when a remote server closes its connection unexpectedly.

struct

(struct bad-newsgroup-line nntp (line)
    #:extra-constructor-name make-bad-newsgroup-line)
  line : string?
Raised when the newsgroup line is improperly formatted.

struct

(struct non-existent-group nntp (group)
    #:extra-constructor-name make-non-existent-group)
  group : string?
Raised when the server does not recognize the name of the requested group.

struct

(struct article-not-in-group nntp (article)
    #:extra-constructor-name make-article-not-in-group)
  article : exact-integer?
Raised when an article is outside the server’s range for that group.

struct

(struct no-group-selected nntp ()
    #:extra-constructor-name make-no-group-selected)
Raised when an article operation is used before a group has been selected.

struct

(struct article-not-found nntp (article)
    #:extra-constructor-name make-article-not-found)
  article : exact-integer?
Raised when the server is unable to locate the article.

struct

(struct authentication-rejected nntp ()
    #:extra-constructor-name make-authentication-rejected)
Raised when the server reject an authentication attempt.

16.3 NNTP Unit🔗ℹ

nntp@ and nntp^ are deprecated. They exist for backward-compatibility and will likely be removed in the future. New code should use the net/nntp module.

 (require net/nntp-unit) package: compatibility-lib

value

nntp@ : unit?

Imports nothing, exports nntp^.

16.4 NNTP Signature🔗ℹ

 (require net/nntp-sig) package: compatibility-lib

signature

nntp^ : signature

Includes everything exported by the net/nntp module.