                 return;
             }
             puts("Facilitator spec: \"" + fac_spec + "\"");
-            parts = fac_spec.split(":", 2);
-            if (parts.length != 2 || !parseInt(parts[1])) {
+            fac_addr = parse_addr_spec(fac_spec);
+            if (!fac_addr) {
                 puts("Error: Facilitator spec must be in the form \"host:port\".");
                 return;
             }
-            fac_address = parts[0];
-            fac_port = parseInt(parts[1]);
 
             go(TOR_ADDRESS, TOR_PORT);
         }


        private function loaderinfo_complete(e:Event):void
        {
            var fac_spec:String, parts:Array;

            puts("Parameters loaded.");
            fac_spec = this.loaderInfo.parameters["facilitator"];

            puts("Facilitator: connected.");

            s_f.addEventListener(ProgressEvent.SOCKET_DATA, function (e:ProgressEvent):void {
                var client_spec:String;
                var client_addr:Object;

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

                client_addr = parse_addr_spec(client_spec);
                if (!client_addr) {
                    puts("Error: Client spec must be in the form \"host:port\".");
                    return;
                }
                if (client_addr.host == "0.0.0.0" && client_addr.port == 0) {
                    puts("Error: Facilitator has no clients.");
                    return;
                }

                puts("Client: connecting to " + client_addr.host + ":" + client_addr.port + ".");
                s_c.connect(client_addr.host, client_addr.port);

            });

