Receive n bytes from a socket, or fail.
(s, n)
| 22 | |
| 23 | # Utility functions |
| 24 | def recvall(s, n): |
| 25 | """Receive n bytes from a socket, or fail.""" |
| 26 | rv = bytearray() |
| 27 | while n > 0: |
| 28 | d = s.recv(n) |
| 29 | if not d: |
| 30 | raise IOError('Unexpected end of stream') |
| 31 | rv.extend(d) |
| 32 | n -= len(d) |
| 33 | return rv |
| 34 | |
| 35 | # Implementation classes |
| 36 | class Socks5Configuration(): |