Package DebTorrent :: Module ServerPortHandler :: Class SingleRawServer
[hide private]
[frames] | no frames]

Class SingleRawServer

source code

Simplified Server to handle one of many torrents.

This class provides a wrapper around a master RawServer.RawServer instance, processing requests with the same interface and passing them on to the master server.

Instance Methods [hide private]
 
__init__(self, info_hash, multihandler, doneflag, protocol)
Initialize the instance.
source code
 
shutdown(self)
Tell the collection to shutdown this torrent.
source code
 
_shutdown(self)
Shutdown this torrent.
source code
 
_external_connection_made(self, c, options, already_read, encrypted=None)
Processes a new socket connection to this torrent.
source code
 
add_task(self, func, delay=0, id=[])
Passes a delayed call to a method on to the master Server.
source code
call graph 
SocketHandler.SingleSocket
start_connection(self, dns, handler=None)
Tell the master Server to start a new connection to a peer.
source code
method
start_listening(self, handler)
Start the Server listening (but not forever).
source code
boolean
is_finished(self)
Check if the torrent download has been shutdown.
source code
threading.Event
get_exception_flag(self)
Get the master Server's exception flag.
source code
Instance Variables [hide private]
threading.Event doneflag
flag to indicate this torrent is being shutdown
boolean finished
whether this torrent has been shutdown
unknown handler
the data handler to use to process data received on the connection
string info_hash
the torrent infohash this Server is responsible for
MultiHandler multihandler
the collection of all individual simplified servers
string protocol
the name of the communication protocol
RawServer.RawServer rawserver
the master Server instance
boolean running
whether this torrent has been started and is running
list taskqueue
unknown
Method Details [hide private]

__init__(self, info_hash, multihandler, doneflag, protocol)
(Constructor)

source code 
Initialize the instance.
Parameters:
  • info_hash (string) - the torrent infohash this Server is responsible for
  • multihandler (MultiHandler) - the collection of all individual simplified servers
  • doneflag (threading.Event) - flag to indicate this torrent is being shutdown
  • protocol (string) - the name of the communication protocol

_external_connection_made(self, c, options, already_read, encrypted=None)

source code 
Processes a new socket connection to this torrent.
Parameters:
  • c (unknown) - the new connection
  • options (unknown) - the protocol options the connected peer supports
  • already_read (string) - the data that has already been read from the connection
  • encrypted (BTcrypto.Crypto) - the Crypto instance to use to encrypt this connections communication (optional, defaults to None)

add_task(self, func, delay=0, id=[])

source code 
call graph 
Passes a delayed call to a method on to the master Server.
Parameters:
  • func (method) - the method to call
  • delay (int) - the number of seconds to delay before calling
  • id (mutable) - the ID of the task

start_connection(self, dns, handler=None)

source code 
Tell the master Server to start a new connection to a peer.
Parameters:
  • dns ((string, int)) - the IP address and port number to contact the peer on
  • handler (unknown) - the data handler to use to process data on the connection (optional, defaults to the handler)
Returns: SocketHandler.SingleSocket
the new connection made to the peer

start_listening(self, handler)

source code 
Start the Server listening (but not forever).
Parameters:
  • handler (unknown) - the default handler to call when data comes in
Returns: method
the method to call to shutdown the torrent download

is_finished(self)

source code 
Check if the torrent download has been shutdown.
Returns: boolean
whether the torrent has been shutdown

get_exception_flag(self)

source code 
Get the master Server's exception flag.
Returns: threading.Event
the flag used to indicate exceptions