| 304 | sock.close() |
| 305 | |
| 306 | class ClientProto(asyncio.Protocol): |
| 307 | def __init__(self, on_data, on_eof): |
| 308 | self.on_data = on_data |
| 309 | self.on_eof = on_eof |
| 310 | self.con_made_cnt = 0 |
| 311 | |
| 312 | def connection_made(proto, tr): |
| 313 | proto.con_made_cnt += 1 |
| 314 | # Ensure connection_made gets called only once. |
| 315 | self.assertEqual(proto.con_made_cnt, 1) |
| 316 | |
| 317 | def data_received(self, data): |
| 318 | self.on_data.set_result(data) |
| 319 | |
| 320 | def eof_received(self): |
| 321 | self.on_eof.set_result(True) |
| 322 | |
| 323 | async def client(addr): |
| 324 | await asyncio.sleep(0.5) |