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


Python Server.listen方法代码示例

本文整理汇总了Python中Server.listen方法的典型用法代码示例。如果您正苦于以下问题:Python Server.listen方法的具体用法?Python Server.listen怎么用?Python Server.listen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server.listen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: len

# 需要导入模块: import Server [as 别名]
# 或者: from Server import listen [as 别名]
import sys

log.startLogging(sys.stdout)

if len(sys.argv) != 4:
    print("Usage: python query.py <bootstrap ip> <bootstrap port> <key>")
    sys.exit(1)

ip = sys.argv[1]
port = int(sys.argv[2])
key = sys.argv[3]

print("Getting %s (with bootstrap %s:%i)" % (key, ip, port))

def done(result):
    print("Key result:")
    print(result)
    reactor.stop()

def bootstrapDone(found, server, key):
    if len(found) == 0:
        print("Could not connect to the bootstrap server.")
        reactor.stop()
    server.get(key).addCallback(done)

server = Server()
server.listen(port)
server.bootstrap([(ip, port)]).addCallback(bootstrapDone, server, key)

reactor.run()
开发者ID:StorjOld,项目名称:storjkademlia,代码行数:32,代码来源:query.py

示例2: Server

# 需要导入模块: import Server [as 别名]
# 或者: from Server import listen [as 别名]
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from twisted.internet import reactor
from storj-kademlia.network import Server

if os.path.isfile('cache.pickle'):
    kserver = Server.loadState('cache.pickle')
else:
    kserver = Server()
    kserver.bootstrap([("1.2.3.4", 8468)])
kserver.saveStateRegularly('cache.pickle', 10)
kserver.listen(8468)
reactor.run()
开发者ID:StorjOld,项目名称:storjkademlia,代码行数:16,代码来源:server.py

示例3: len

# 需要导入模块: import Server [as 别名]
# 或者: from Server import listen [as 别名]
from Client import *
from Server import *

from functools import partial
import threading
import time
import sys

if len(sys.argv) != 2:
	print "usage: python clique.py <VM password>"
	sys.exit()
password = sys.argv[1]

srv1 = Server("vm12c10v01", "192.168.1.1", password)
srv1.setType("tcp")
srv1.listen("5201")
srv1.listen("5202")
srv1.listen("5203")
srv1.start("5")

srv2 = Server("vm12c11v01", "192.168.1.2", password)
srv2.setType("tcp")
srv2.listen("5201")
srv2.listen("5202")
srv2.listen("5203")
srv2.start("5")

srv3 = Server("vm12c12v01", "192.168.1.4", password)
srv3.setType("tcp")
srv3.listen("5201")
srv3.listen("5202")
开发者ID:DoctorSher,项目名称:python-iperf,代码行数:33,代码来源:clique.py

示例4: enumerate

# 需要导入模块: import Server [as 别名]
# 或者: from Server import listen [as 别名]
	if key.startswith('vm12c12'):
		srvmap[key] = value
		# climap[key] = value
	else:
		climap[key] = value
		# srvmap[key] = value

clients = []
servers = []
threads = []

numPairs = 2
for idx, key in enumerate(srvmap):
	if idx >= numPairs: continue
	srv = Server(key, srvmap[key])
	srv.listen("5201")
	srv.start()
	servers.append(srv)

srvlist = srvmap.items()
for idx, key in enumerate(climap):
	if idx >= numPairs: continue
	cli = Client(key, climap[key])
	cli.setTarget(srvlist[idx][1], "5201")
	cli.setType("udp")
	# cli.setUdpOptions("495m")
	cli.setUdpOptions("495m","1400")
	clients.append(cli)
	print key,climap[key] + " sends to " + srvlist[idx][0],srvlist[idx][1]

for cli in clients:
开发者ID:DoctorSher,项目名称:python-iperf,代码行数:33,代码来源:exp.py


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