Package Anomos :: Package Protocol :: Module BitTorrentProtocol :: Class BitTorrentProtocol
[hide private]
[frames] | no frames]

Class BitTorrentProtocol

source code

object --+
         |
        BitTorrentProtocol

Should NOT be created directly, must be used as a mixin with a class that also inherits a Connection type

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
write_header(self)
Return properly formatted BitTorrent connection header...
source code
 
protocol_extensions(self)
The BitTorrent protocol has 8 reserved bytes in its header
source code
 
_read_header(self)
Yield the number of bytes for each section of the header and sanity check the received values.
source code
 
_got_full_header(self) source code
 
_read_messages(self)
Read messages off the line and relay or process them depending on connection type
source code
 
_valid_msg_len(self, m)
Check length of received message m against dictionary of valid message lengths
source code
 
transfer_ctl_msg(self, type, message='')
Send method for file transfer messages.
source code
 
got_message(self, message)
Handles an incoming message.
source code
 
got_choke(self) source code
 
got_unchoke(self) source code
 
got_interested(self) source code
 
got_not_interested(self) source code
 
got_have(self, message) source code
 
got_bitfield(self, message) source code
 
got_request(self, message) source code
 
got_cancel(self, message) source code
 
got_piece(self, message) source code
 
send_interested(self) source code
 
send_not_interested(self) source code
 
send_choke(self) source code
 
send_unchoke(self) source code
 
send_request(self, index, begin, length) source code
 
send_cancel(self, index, begin, length) source code
 
send_bitfield(self, bitfield) source code
 
send_have(self, index) source code
 
format_message(self, type, message='')
[Message Length][Type][Payload]
source code
 
partial_msg_str(self, index, begin, piece) source code
 
partial_choke_str(self) source code
 
partial_unchoke_str(self) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  protocol_name = 'BitTorrent'
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

write_header(self)

source code 
Return properly formatted BitTorrent connection header
example with port 6881 and id 255:
      BitTorrentá

_read_header(self)

source code 

Yield the number of bytes for each section of the header and sanity check the received values. If the connection doesn't have a header (as in, it's already established) then switch to _read_message and reenter the data we read off as if it just came in.

transfer_ctl_msg(self, type, message='')

source code 

Send method for file transfer messages. ie. CHOKE, INTERESTED, PIECE

got_message(self, message)

source code 

Handles an incoming message. First byte designates message type, may be any one of (CHOKE, UNCHOKE, INTERESTED, NOT_INTERESTED, HAVE, BITFIELD, REQUEST, PIECE, CANCEL)