MCPcopy
hub / github.com/dabeaz/python-cookbook / echo_client

Function echo_client

src/12/how_to_create_a_thread_pool/example1.py:4–15  ·  view source on GitHub ↗

Handle a client connection

(sock, client_addr)

Source from the content-addressed store, hash-verified

2from concurrent.futures import ThreadPoolExecutor
3
4def echo_client(sock, client_addr):
5 '''
6 Handle a client connection
7 '''
8 print('Got connection from', client_addr)
9 while True:
10 msg = sock.recv(65536)
11 if not msg:
12 break
13 sock.sendall(msg)
14 print('Client closed connection')
15 sock.close()
16
17def echo_server(addr):
18 print('Echo server running at', addr)

Callers

nothing calls this directly

Calls 2

recvMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected