def joinNetwork(self, knownPeerAddresses=None): """ Causes the Peer to join the Kademlia network; normally, this should be called before any other DHT operations. @param knownPeerAddresses: A sequence of tuples containing IP address information for existing peers on the Kademlia network, in the format: C{(<ip address>, (udp port>)} @type knownPeerAddresses: tuple """ DHTPeer.joinNetwork(self, knownPeerAddresses) twisted.internet.reactor.callLater(15, self._startTupleTrack)
def createPeer(port=4000,ipaddress=None,startport=None): #import twisted.internet.reactor import sys, os if ipaddress != None: knownPeers = [(ipaddress, startport)] else: knownPeers = None #print knownPeers, port peer = DHTPeer(udpPort=port) peer.joinNetwork(knownPeers) #peer.printNeighbors() #print port,ipaddress,startPort return peer