MCPcopy
hub / github.com/dabeaz-course/python-mastery / echo_handler

Function echo_handler

Solutions/8_5/server.py:41–50  ·  view source on GitHub ↗
(client, address)

Source from the content-addressed store, hash-verified

39 tasks.append(handler(client, addr))
40
41def 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
52if __name__ == '__main__':
53 tasks.append(tcp_server(('',25000), echo_handler))

Callers

nothing calls this directly

Calls 2

recvMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected