Tcl Library Source Code

Documentation
Login


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]

NAME

bee - BitTorrent Serialization Format Encoder/Decoder

Table Of Contents

SYNOPSIS

package require Tcl 8.4
package require bee ?0.1?

::bee::encodeString string
::bee::encodeNumber integer
::bee::encodeListArgs value...
::bee::encodeList list
::bee::encodeDictArgs key value...
::bee::encodeDict dict
::bee::decode string ?endvar? ?start?
::bee::decodeIndices string ?endvar? ?start?
::bee::decodeChannel chan -command cmdprefix ?-exact? ?-prefix data?
cmdprefix eof token
cmdprefix error token message
cmdprefix value token value
::bee::decodeCancel token
::bee::decodePush token string

DESCRIPTION

The bee package provides de- and encoder commands for data in bencoding (speak 'bee'), the serialization format for data and messages used by the BitTorrent protocol.

PUBLIC API

ENCODER

The package provides one encoder command for each of the basic forms, and two commands per container, one taking a proper tcl data structure to encode in the container, the other taking the same information as several arguments.

DECODER

The package provides two main decoder commands, one for decoding a string expected to contain a complete data structure, the other for the incremental decoding of bee-values arriving on a channel. The latter command is asynchronous and provides the completed decoded values to the user through a command callback.

FORMAT DEFINITION

Data in the bee serialization format is constructed from two basic forms, and two container forms. The basic forms are strings and integer numbers, and the containers are lists and dictionaries.

Note that the type of each encoded item can be determined immediately from the first character of its representation:

By wrapping an integer number into i...e the format makes sure that they are different from strings, which all begin with a digit.

EXAMPLES

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category bee of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.

KEYWORDS

BitTorrent, bee, bittorrent, serialization, torrent

CATEGORY

Networking

COPYRIGHT

Copyright © 2004 Andreas Kupries