Пример #1
0
 def test_estimate_write_capacity_client(self):
     testutil.DummyReadWorker((HOST, PORT))
     client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sleep(1)
     client_socket.connect((HOST, PORT))
     buf_capacity = estimate_write_capacity(client_socket)
     i = 0
     while buf_capacity > const.MTU:
         client_socket.sendall('\0' * const.MTU)
         buf_capacity = estimate_write_capacity(client_socket)
         print i, buf_capacity
         i += 1
     self.assertTrue(buf_capacity <= const.MTU)
     client_socket.close()
Пример #2
0
 def test_estimate_write_capacity_server(self):
     testutil.DummyWriteWorker((HOST, PORT))
     listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     listener.bind((HOST, PORT))
     listener.listen(1)
     (conn, _) = listener.accept()
     listener.close()
     try:
         i = 0
         while True:
             conn.recv(4096)
             buf_capacity = estimate_write_capacity(conn)
             print i, buf_capacity
             i += 1
     except Exception, e:
         print "[ReadWorker] Exception %s" % str(e)