| 513 | |
| 514 | # 65535, the default value of x is the maximum length of a TLS record |
| 515 | def recv(self, x=None, **kwargs): |
| 516 | # type: (Optional[int], **Any) -> Optional[Packet] |
| 517 | if x is None: |
| 518 | x = MTU |
| 519 | # Block |
| 520 | try: |
| 521 | data = self.ins.recv(x) |
| 522 | except OSError: |
| 523 | raise EOFError |
| 524 | try: |
| 525 | pkt = self.sess.process(data, cls=self.basecls) # type: ignore |
| 526 | except struct.error: |
| 527 | # Buffer underflow |
| 528 | pkt = None |
| 529 | if data == b"" and not pkt: |
| 530 | raise EOFError |
| 531 | if not pkt: |
| 532 | return self.recv(x) |
| 533 | return pkt |
| 534 | |
| 535 | @staticmethod |
| 536 | def select(sockets, remain=None): |