本文整理汇总了Python中SocketServer.ThreadingTCPServer.allow_reuse_address方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadingTCPServer.allow_reuse_address方法的具体用法?Python ThreadingTCPServer.allow_reuse_address怎么用?Python ThreadingTCPServer.allow_reuse_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketServer.ThreadingTCPServer
的用法示例。
在下文中一共展示了ThreadingTCPServer.allow_reuse_address方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from SocketServer import ThreadingTCPServer [as 别名]
# 或者: from SocketServer.ThreadingTCPServer import allow_reuse_address [as 别名]
def main():
i2t_server = ThreadingTCPServer(('', PORT), I2T_Handler)
i2t_server.allow_reuse_address = True
print "listening on port", PORT
i2t_threads = threading.Thread(target = i2t_server.serve_forever)
i2t_threads.setDaemon(True)
i2t_threads.start()
print "Image2Torrent Machine started..."
raw_input()
示例2: ThreadingTCPServer
# 需要导入模块: from SocketServer import ThreadingTCPServer [as 别名]
# 或者: from SocketServer.ThreadingTCPServer import allow_reuse_address [as 别名]
while True:
self.data = self.request.recv(1024)
if not self.data: break
gLock.acquire()
print "Server received {0} bytes on thread {1} from {2}:{3}".format(len(self.data),
threading.current_thread().name, *self.client_address)
print " {0}".format(self.data)
gLock.release()
self.request.send(self.data)
try:
s = ThreadingTCPServer((server_addr, server_port), EchoHandler)
s.allow_reuse_address = True
print "Server started"
s.serve_forever()
except (KeyboardInterrupt, SystemExit):
pass
finally:
s.shutdown()
print "Server stopped"
示例3: open
# 需要导入模块: from SocketServer import ThreadingTCPServer [as 别名]
# 或者: from SocketServer.ThreadingTCPServer import allow_reuse_address [as 别名]
self.request.sendall('filesize:'+str(size))
self.data = self.request.recv(1024).strip()
if self.data == 'ok':
break
fp = open('coreseek.tar.gz', 'r')
#for line in file('Config.py'):
#self.request.sendall(line.strip())
while True:
content = fp.read(8192)
if content == '':
break
self.request.sendall(content)
except Exception, e:
print e
print username, ' closed.'
if __name__ == "__main__":
HOST, PORT = "localhost", 9999
#server = TCP((HOST, PORT), ReceiveServer)
server = ThreadingTCPServer((HOST, PORT), ReceiveServer)
server.allow_reuse_address = True
server.serve_forever()
示例4: create_server
# 需要导入模块: from SocketServer import ThreadingTCPServer [as 别名]
# 或者: from SocketServer.ThreadingTCPServer import allow_reuse_address [as 别名]
def create_server(addr, port, handler):
server = ThreadingTCPServer((addr, port), handler, bind_and_activate=False)
server.allow_reuse_address = True
server.server_bind()
server.server_activate()
server.serve_forever()