本文整理匯總了Python中transport.Transport.clientSend方法的典型用法代碼示例。如果您正苦於以下問題:Python Transport.clientSend方法的具體用法?Python Transport.clientSend怎麽用?Python Transport.clientSend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類transport.Transport
的用法示例。
在下文中一共展示了Transport.clientSend方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from transport import Transport [as 別名]
# 或者: from transport.Transport import clientSend [as 別名]
def main():
random.seed(0)
d = Driver()
t = Transport(d, isServer=False)
services = Services(t)
s = services.getService(TEST_ADDRESS)
for i in itertools.count(1):
#totalFrags = random.randrange(1, 2**16 - 1)
totalFrags = random.randrange(1, 500)
#totalFrags = 1000
requestBuffer = Buffer(['a' * t.dataPerFragment() for j in range(totalFrags)])
responseBuffer = Buffer()
start = gettime()
r = t.clientSend(s, requestBuffer, responseBuffer)
r.getReply()
elapsedNs = gettime() - start
resp = responseBuffer.getRange(0, responseBuffer.getTotalLength())
req = requestBuffer.getRange(0, requestBuffer.getTotalLength())
assert len(req) == len(resp), (len(req), len(resp), req[:10], resp[:10],
req[-10:], resp[-10:])
assert req == resp, (req, resp)
print
print "Message %d with %d frags OK in %dms" % (i, totalFrags,
elapsedNs / 1000000)
d.stat()