             "," + this.addr_r.host + ":" + this.addr_r.port + ">";
     }
 
-    public function ProxyPair(ui:swfcat, addr_c:Object, addr_r:Object)
+    public function ProxyPair(ui:swfcat, addr_c:Object, addr_r:Object, rate_limit:uint = DEFAULT_RATE_LIMIT)
     {
         this.ui = ui;
         this.addr_c = addr_c;
         this.addr_r = addr_r;
+        this.rate_limit = rate_limit;
+        this.curr_rate = 0.0;
+        this.historical_rate = 0.0;
+        this.lifetime = 0;
+        setInterval(update_transfer_rate, DEFAULT_RATE_TIMEOUT)
     }
 
     public function connect():void

    private function client_connected(e:Event):void
    {
        log("Client: connected.");

        s_r.addEventListener(ProgressEvent.SOCKET_DATA, function (e:ProgressEvent):void {
            var bytes:ByteArray = new ByteArray();
            s_r.readBytes(bytes, 0, e.bytesLoaded);
            log("Tor: read " + bytes.length + ".");
            s_c.writeBytes(bytes);
        });
        s_c.addEventListener(ProgressEvent.SOCKET_DATA, function (e:ProgressEvent):void {
            var bytes:ByteArray = new ByteArray();
            s_c.readBytes(bytes, 0, e.bytesLoaded);
            log("Client: read " + bytes.length + ".");
            s_r.writeBytes(bytes);
        });
    }
}

import flash.events.SecurityErrorEvent;
import flash.net.Socket;
import flash.utils.ByteArray;
import flash.utils.setInterval;

/* An instance of a client-relay connection. */
class ProxyPair
