(client, address)
| 39 | tasks.append(handler(client, addr)) |
| 40 | |
| 41 | def echo_handler(client, address): |
| 42 | print('Connection from', address) |
| 43 | while True: |
| 44 | yield 'recv', client |
| 45 | data = client.recv(1000) |
| 46 | if not data: |
| 47 | break |
| 48 | yield 'send', client |
| 49 | client.send(b'GOT:' + data) |
| 50 | print('Connection closed') |
| 51 | |
| 52 | if __name__ == '__main__': |
| 53 | tasks.append(tcp_server(('',25000), echo_handler)) |