socket_parent.py 文件源码

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

项目:reversi_ai 作者: andysalerno 项目源码 文件源码
def recv_bytes(self, connection):
        """
        Given a socket connection, receive up to 2048 bytes
        from its buffer and return that data as a bytes object.
        Returns an empty bytes object if there is no data to receive.
        """
        try:
            bytes_message = connection.recv(2048)
        except BlockingIOError:
            # Non-blocking socket couldn't immediately receive.
            return None
        except ConnectionResetError:
            self._print_message('Connection was reset.')
            self.connection.close()
            _thread.interrupt_main()

        return bytes_message
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号