| 87 | # |
| 88 | |
| 89 | def _pollForNetBIOSPacket(self, wait_trn_id, timeout): |
| 90 | end_time = time.time() - timeout |
| 91 | while True: |
| 92 | try: |
| 93 | _timeout = time.time()-end_time |
| 94 | if _timeout <= 0: |
| 95 | return None |
| 96 | |
| 97 | ready, _, _ = select.select([ self.sock.fileno() ], [ ], [ ], _timeout) |
| 98 | if not ready: |
| 99 | return None |
| 100 | |
| 101 | data, _ = self.sock.recvfrom(0xFFFF) |
| 102 | if len(data) == 0: |
| 103 | raise NotConnectedError |
| 104 | |
| 105 | trn_id, ret = self.decodePacket(data) |
| 106 | |
| 107 | if trn_id == wait_trn_id: |
| 108 | return ret |
| 109 | except select.error as ex: |
| 110 | if type(ex) is tuple: |
| 111 | if ex[0] != errno.EINTR and ex[0] != errno.EAGAIN: |
| 112 | raise ex |
| 113 | else: |
| 114 | raise ex |
| 115 | |
| 116 | # |
| 117 | # Contributed by Jason Anderson |