Skip to content

Instantly share code, notes, and snippets.

@ph1ee
Last active January 10, 2020 07:29
Show Gist options
  • Save ph1ee/517fc5538e582b3d102171f370f55d4b to your computer and use it in GitHub Desktop.
Save ph1ee/517fc5538e582b3d102171f370f55d4b to your computer and use it in GitHub Desktop.
simple discard daemon
#!/usr/bin/env python3
import socketserver
class TCPHandler(socketserver.StreamRequestHandler):
def handle(self):
while self.rfile.read(1):
pass
if __name__ == "__main__":
HOST, PORT = "0.0.0.0", 9999
# Create the server, binding to localhost on port 9999
server = socketserver.TCPServer((HOST, PORT), TCPHandler)
server.allow_reuse_address = True
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment