MCPcopy Index your code
hub / github.com/dabeaz-course/python-mastery / tcp_server

Function tcp_server

Solutions/8_6/server.py:51–58  ·  view source on GitHub ↗
(address, handler)

Source from the content-addressed store, hash-verified

49 return getattr(self.sock, name)
50
51def tcp_server(address, handler):
52 sock = GenSocket(socket(AF_INET, SOCK_STREAM))
53 sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
54 sock.bind(address)
55 sock.listen(5)
56 while True:
57 client, addr = yield from sock.accept()
58 tasks.append(handler(client, addr))
59
60def echo_handler(client, address):
61 print('Connection from', address)

Callers 1

server.pyFile · 0.70

Calls 3

acceptMethod · 0.95
appendMethod · 0.80
GenSocketClass · 0.70

Tested by

no test coverage detected