def available(self):
"""
Get the available bytes, cutting off the suffix if
it's been acocunted for
"""
if not self._rawStreamSize() >= (self.PREFIX_SIZE + self.SUFFIX_SIZE):
return 0
curPos = self._stream.tell()
# even if the suffix hasn't been received yet, we calculate our offsets as if it had.
# why? because if it hasn't been received yet, we don't want to finish! The whole packet
# isn't framed (verified) until the final bytes are received.
self._stream.seek(-self.SUFFIX_SIZE, SEEK_END)
endPos = self._stream.tell()
self._stream.seek(curPos)
return endPos-curPos
评论列表
文章目录