MCPcopy Create free account
hub / github.com/dabeaz/python-cookbook / echo_server

Function echo_server

src/11/creating_a_tcp_server/echoserv5.py:14–20  ·  view source on GitHub ↗
(address, backlog=5)

Source from the content-addressed store, hash-verified

12 client_sock.close()
13
14def echo_server(address, backlog=5):
15 sock = socket(AF_INET, SOCK_STREAM)
16 sock.bind(address)
17 sock.listen(backlog)
18 while True:
19 client_sock, client_addr = sock.accept()
20 echo_handler(client_addr, client_sock)
21
22if __name__ == '__main__':
23 echo_server(('', 20000))

Callers 1

echoserv5.pyFile · 0.70

Calls 2

acceptMethod · 0.80
echo_handlerFunction · 0.70

Tested by

no test coverage detected