def recv(self):
with self.lock:
if not (self.state.ESTABLISHED or self.state.CLOSE_WAIT):
self.err("recv() in socket state {0}".format(self.state))
raise Error(errno.ENOTCONN)
try: pdu = super(DataLinkConnection, self).recv()
except IndexError: return None
if isinstance(pdu, Information):
self.recv_confs += 1
if self.recv_confs > self.recv_win:
self.err("recv_confs({0}) > recv_win({1})"
.format(self.recv_confs, self.recv_win))
raise RuntimeError("recv_confs > recv_win")
return pdu.sdu
if isinstance(pdu, Disconnect):
self.close()
return None
raise RuntimeError("only I or DISC expected, not "+ pdu.name)
评论列表
文章目录