2014-10-17 15:08:41 +00:00
|
|
|
import SocketServer
|
|
|
|
from time import sleep
|
|
|
|
|
2015-05-30 00:03:28 +00:00
|
|
|
|
2014-10-17 15:08:41 +00:00
|
|
|
class service(SocketServer.BaseRequestHandler):
|
|
|
|
def handle(self):
|
|
|
|
data = 'dummy'
|
|
|
|
print "Client connected with ", self.client_address
|
|
|
|
while True:
|
2015-05-30 00:03:28 +00:00
|
|
|
self.request.send(
|
|
|
|
"HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 7\r\n\r\ncontent")
|
2014-10-17 15:08:41 +00:00
|
|
|
data = self.request.recv(1024)
|
|
|
|
if not len(data):
|
|
|
|
print "Connection closed by remote: ", self.client_address
|
|
|
|
sleep(3600)
|
|
|
|
|
|
|
|
|
|
|
|
class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
|
|
|
|
pass
|
|
|
|
|
2015-05-30 00:03:28 +00:00
|
|
|
server = ThreadedTCPServer(('', 1520), service)
|
2014-10-17 15:08:41 +00:00
|
|
|
server.serve_forever()
|