Created
November 12, 2014 15:03
-
-
Save apg/ecd7f22b372b4bb442e3 to your computer and use it in GitHub Desktop.
one line echo server in python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import itertools | |
(lambda port, s=socket.socket(socket.AF_INET, socket.SOCK_STREAM): | |
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) == None and | |
s.bind(('', port)) == None and | |
s.listen(5) == None and | |
list(map(lambda c: | |
c[0].sendall(c[0].recv(1024)) and | |
c[0].close(), | |
(s.accept() for _ in itertools.count(1)))) != None and | |
s.close())(PORT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment