Example #1
0
def generateCancel(index, begin, length):
    return _createMessageLength(13)+shortIntToBinary(8)+\
           longIntToBinary(index)+\
           longIntToBinary(begin)+\
           longIntToBinary(length)
Example #2
0
def generatePiece(index, begin, block):
    return _createMessageLength(9+len(block))+shortIntToBinary(7)+\
           longIntToBinary(index)+\
           longIntToBinary(begin)+\
           block
Example #3
0
def generateHave(pieceIndex):
    return _createMessageLength(5)+shortIntToBinary(4)+longIntToBinary(pieceIndex)
Example #4
0
def generateRequest(index, begin, length):
    return _createMessageLength(13)+shortIntToBinary(6)+\
           longIntToBinary(index)+\
           longIntToBinary(begin)+\
           longIntToBinary(length)
Example #5
0
def _createMessageLength(length):
    return longIntToBinary(length)