                 s_r.close();
             dispatchEvent(new Event(Event.COMPLETE));
         });
+        s_c.addEventListener(ProgressEvent.SOCKET_DATA, client_to_relay);
 
         log("Client: connecting to " + addr_c.host + ":" + addr_c.port + ".");
         s_c.connect(addr_c.host, addr_c.port);

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

        s_r.addEventListener(ProgressEvent.SOCKET_DATA, relay_to_client);
        s_c.addEventListener(ProgressEvent.SOCKET_DATA, client_to_relay);
    }

    private function transfer_chunk(s_from:Socket, s_to:Socket, n:uint,

            if (c2r_schedule.length > 0)
                transfer_chunk(s_c, s_r, c2r_schedule.shift(), "Client");
        }

        /* Call again when safe, if necessary. */
        if (r2c_schedule.length > 0 || c2r_schedule.length > 0)
            flush_id = setTimeout(flush, ui.rate_limit.when() * 1000);
