-# Copyright (c) 2011 Nicira Networks
+# Copyright (c) 2011, 2012 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
def __init__(self):
self.stats = 0
- def connectionMade(self):
- print "Started TCP Listener connection"
-
def dataReceived(self, data):
self.stats += len(data)
def connectionLost(self, reason):
- print "Stopped TCP Listener connection"
self.factory.stats += self.stats
def __init__(self):
self.stats = 0
- def startFactory(self):
- print "Starting TCP listener factory"
-
- def stopFactory(self):
- print "Stopping TCP listener factory"
-
def getResults(self):
""" returns the number of bytes received as string"""
- #XML RPC does not support 64bit int (http://bugs.python.org/issue2985)
- #so we have to convert the amount of bytes into a string
+ # XML RPC does not support 64bit int (http://bugs.python.org/issue2985)
+ # so we have to convert the amount of bytes into a string
return str(self.stats)
"""
def connectionMade(self):
- print "Started TCP sender connection"
producer = Producer(self, self.factory.duration)
self.transport.registerProducer(producer, True)
producer.resumeProducing()
def dataReceived(self, data):
- print "Sender received data!", data
self.transport.loseConnection()
- def connectionLost(self, reason):
- print "Stopped TCP sender connection"
-
class TcpSenderFactory(ClientFactory):
"""
self.duration = duration
self.stats = 0
- def startFactory(self):
- print "Starting TCP sender factory"
-
- def stopFactory(self):
- print "Stopping TCP sender factory"
-
def getResults(self):
"""Returns amount of bytes sent to the Listener (as a string)"""
return str(self.stats)