 
         // Socket to Tor relay.
         private var s_t:Socket;
-	// Socket to Facilitator.
-	private var s_f:Socket;
+        // Socket to facilitator.
+        private var s_f:Socket;
         // Socket to client.
         private var s_c:Socket;
 
         private var fac_address:String;
         private var fac_port:int;
 
-	private var client_address:String;
-	private var client_port:int;
+        private var client_address:String;
+        private var client_port:int;
 
         private function puts(s:String):void
         {


            puts("Facilitator: connecting to " + fac_address + ":" + fac_port + ".");
            s_f.connect(fac_address, fac_port);

            /*s_c = new Socket();

            puts("Tor: connected.");
            s_c.addEventListener(Event.CONNECT, client_connected);
            s_c.addEventListener(Event.CLOSE, function (e:Event):void {
                puts("Client: closed.");
                if (s_t.connected)
                    s_t.close();
            });
            s_c.addEventListener(IOErrorEvent.IO_ERROR, function (e:IOErrorEvent):void {
                puts("Client: I/O error: " + e.text + ".");
                if (s_t.connected)
                    s_t.close();
            });
            s_c.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function (e:SecurityErrorEvent):void {
                puts("Client: security error: " + e.text + ".");
                if (s_t.connected)
                    s_t.close();
            });

            puts("Client: connecting to " + client_address + ":" + client_port + ".");
            s_c.connect(client_address, client_port);*/
        }
        
	private function fac_connected(e:Event):void
        {
            puts("Facilitator: connected.");

            s_f.addEventListener(ProgressEvent.SOCKET_DATA, function (e:ProgressEvent):void {
                var client_spec:String = new String();
		var parts:Array;

		client_spec = s_f.readMultiByte(e.bytesLoaded, "utf-8");
                puts("Facilitator: got \"" + client_spec + "\"");

                parts = client_spec.split(":", 2);
                if (parts.length != 2 || !parseInt(parts[1])) {
                   puts("Error: Facilitator spec must be in the form \"host:port\".");
                   return;
                }
		if (parts[0] == "0.0.0.0" && parseInt(parts[1]) == 0) {
		   puts("Error: Facilitator has no clients.");
		   return;
		}
                client_address = parts[0];
                client_port = parseInt(parts[1]); 

            	puts("Client: connecting to " + client_address + ":" + client_port + ".");
            	s_c.connect(client_address, client_port);

            });
	   
	    s_f.writeUTFBytes("GET / HTTP/1.0\r\n\r\n");
        }

        private function client_connected(e:Event):void

                return;
            }
            fac_address = parts[0];
            fac_port = parseInt(parts[1]);

            go(TOR_ADDRESS, TOR_PORT);
        }

        /* We connect first to the Tor relay; once that happens we connect to
           the facilitator to get a client address; once we have the address
           of a waiting client then we connect to the client and BAM! we're in business. */
        private function go(tor_address:String, tor_port:int):void
        {
            s_t = new Socket();
