当前位置: 首页>>代码示例>>Python>>正文


Python ThreadingTCPServer.allow_reuse_address方法代码示例

本文整理汇总了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()
开发者ID:swmaestro2012,项目名称:somap312_31,代码行数:11,代码来源:i2tServer.py

示例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"
 


开发者ID:r3dlight,项目名称:python-scripts,代码行数:28,代码来源:SocketServer_Shay.py

示例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()

开发者ID:zyong,项目名称:publishSystem,代码行数:31,代码来源:Server.py

示例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()
开发者ID:virtdev,项目名称:virtdev,代码行数:8,代码来源:util.py


注:本文中的SocketServer.ThreadingTCPServer.allow_reuse_address方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。