def _recv_msg(sock,size,timeout):
_sock_timeout_recv(sock,timeout)
try:
chunk=sock.recv(size, socket.MSG_WAITALL) # receive all data in one call
except TypeError:
# M2Crypto sock.recv() doesn't support MSG_WAITALL parameter
return __recv_msg_compat(sock,size,timeout)
else:
if len(chunk)!=size:
err=ConnectionClosedError('connection lost')
err.partialMsg=chunk # store the message that was received until now
raise err
return chunk
评论列表
文章目录