PacketFramingStream.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Playground3 作者: CrimsonVista 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号