Created
July 19, 2012 16:29
-
-
Save jizhang/3145114 to your computer and use it in GitHub Desktop.
simple socket server
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 SocketServer | |
class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): | |
def handle(self): | |
self.request.sendall(""" | |
<?xml version="1.0" encoding="utf-8"?> | |
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> | |
<cross-domain-policy><site-control permitted-cross-domain-policies="all"/> | |
<allow-access-from domain="*.aifang.com" to-ports="*" /> | |
<allow-access-from domain="*.pages.aifcdn.com" to-ports="*" /> | |
<allow-access-from domain="*.aifcdn.com" to-ports="*" /> | |
<allow-access-from domain="anjuke.adsame.com" to-ports="*" /> | |
<allow-access-from domain="anjuke.adsame.com" to-ports="*" /> | |
</cross-domain-policy> | |
""") | |
class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): | |
allow_reuse_address = True | |
if __name__ == "__main__": | |
HOST, PORT = "", 843 | |
server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler) | |
try: | |
server.serve_forever() | |
except KeyboardInterrupt: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment