client.py 文件源码

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

项目:knowledge-management 作者: dgore7 项目源码 文件源码
def retrieve_groups(self, username):
        connection = self.sock
        connection.send("groups_retrieve".encode())
        result = connection.recv(1024)

        if result != SUCCESS:
            print("failed in retrieve groups1")
            return []

        message = "username:" + username
        message = message.encode()
        connection.send(message)
        result = connection.recv(2)

        if result != SUCCESS:
            print("No groups found")
            return []

        chunks = []
        while True:
            bytes_received = connection.recv(1024)
            if bytes_received == SOCKET_EOF:
                break
            else:
                chunks.append(bytes_received)
        result = b''.join(chunks)
        try:
            groups = pickle.loads(result)
        except UnpicklingError:
            return []
        return groups
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号