| 834 | sock.close() |
| 835 | |
| 836 | class ClientProtoFirst(asyncio.BufferedProtocol): |
| 837 | def __init__(self, on_data): |
| 838 | self.on_data = on_data |
| 839 | self.buf = bytearray(1) |
| 840 | |
| 841 | def connection_made(self, tr): |
| 842 | nonlocal client_con_made_calls |
| 843 | client_con_made_calls += 1 |
| 844 | |
| 845 | def get_buffer(self, sizehint): |
| 846 | return self.buf |
| 847 | |
| 848 | def buffer_updated(self, nsize): |
| 849 | assert nsize == 1 |
| 850 | self.on_data.set_result(bytes(self.buf[:nsize])) |
| 851 | |
| 852 | def eof_received(self): |
| 853 | pass |
| 854 | |
| 855 | class ClientProtoSecond(asyncio.Protocol): |
| 856 | def __init__(self, on_data, on_eof): |