Tony Garnock-Jones <tonygarnockjones@gmail.com>
If you find that this library lacks some feature you need, or you have a suggestion for improving it, please don’t hesitate to get in touch with me!
This library implements Bencode, "the encoding used by the peer-to-peer file sharing system BitTorrent for storing and transmitting loosely structured data." Quote from Wikipedia.
Bencode is defined as part of the BitTorrent specifications. Useful references include:
Bencode terms are represented as Racket data structures as follows:
Bencode lists map to Racket lists
Bencode dictionaries map to Racket equal? -hashtables
Bencode integers map to Racket integers
Bencode strings map to Racket byte-vectors (bytes )
In particular, Racket’s null value is the representation of the empty Bencode list.
All the functionality below can be accessed with a single require :
procedure
( bencode-read p)→(or/c any?eof-object? )
If a Bencoded string (Racket bytes) value appears on the input-port and has length in excess of bencode-bytes-limit ’s current value, an error is signalled.
procedure
( bencode-read-to-end p)→list?
procedure
( bytes->bencode bs)→list?
bs:bytes?
procedure
new-limit:integer?
procedure
( bencode-write termp)→void?
term:any?
procedure
( bencode->bytes terms)→bytes?
terms:list?