3:0
top
← prev up next →

bencode: BitTorrent Bencode DecodingπŸ”— i

Neil Van Dyke

License: LGPLv3 Web: http://www.neilvandyke.org/racket/bencode/
(require bencode ) package: bencode

1IntroductionπŸ”— i

The bencode package is for parsing the bencoding format of the BitTorrent network protocol into basic Racket data types. This is useful for inspecting .torrent files, and might be useful in the implementation of a BitTorrent client or protocol analyzer.
The format interpretation is based on the undated BitTorrent protocol documentation Web page as viewed on 2005εΉ΄04月17ζ—₯. The mapping from those bencoding types to Racket types is:
  • String — Racket byte string.

  • Integer — Racket integer.

  • List — Racket list.

  • Dictionary — Racket list with the symbol dictionary as its head, and an association list as its tail. (This is for historical reasons, from when this package was for Scheme; were this package written today, this type would be a hash.)

For example, a parse of a certain real-world .torrent file:

> (unbencode(open-input-file"debian.torrent"))

((dictionary
(#"announce". #"http://cdimage.debian.org:6969/announce")
(#"comment". #"Debian CD from cdimage.debian.org")
(#"creation date". 1105009474)
(#"info"
dictionary
(#"length". 600158208)
(#"name". #"debian-30r4-i386-binary-1.iso")
(#"piece length". 524288)
(#"pieces". [...large byte string...]))))

2InterfaceπŸ”— i

procedure

( unbencode-singleport)list?

port:input-port?
Parses a single bencoding object (and any child objects, in the case of a list or dictionary) from input port port and yields the Racket representation.

procedure

( unbencodeport)list?

port:input-port?
Yields a list of the Racket representations of all bencoding objects parsed from input port port.

3HistoryπŸ”— i

  • Version 3:0 — 2016εΉ΄02月28ζ—₯
    • Moving from PLaneT to new package system

  • Version 2:0 — 2012εΉ΄06月12ζ—₯
    • Converted to McFly.

    • Changed package home page URL.

  • Version 1:1 — 2009εΉ΄03月03ζ—₯
    • Library is now LPGL 3.

    • Converted to author’s new Scheme administration system.

  • Version 1:0 — 2005εΉ΄04月17ζ—₯
    • Initial release.

4LegalπŸ”— i

Copyright (c) 2005, 2009, 2012, 2016 Neil Van Dyke. This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See http://www.gnu.org/licenses/ for details. For other licenses and consulting, please contact the author.

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /