misc/python/echo.py
2018-08-05 18:53:07 +02:00

12 lines
436 B
Python

## Single-expression echo server
(lambda s=__import__('socket'), i=__import__('itertools'):
lambda port=9000, r=s.socket(s.AF_INET, s.SOCK_STREAM):
all(r.setsockopt(s.SOL_SOCKET, s.SO_REUSEADDR, 1),
r.bind(('', port)),
r.listen(5),
set(map(lambda c:
c[0].sendall(c[0].recv(1024)) and
c[0].close(),
(r.accept() for _ in i.count(1))))))()()