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
评论列表
文章目录