function attemptSingleConnect() {
        var deferred = $.Deferred();
        var port = null;
        var ws = null;
        setDeferredTimeout(deferred, CONNECTION_TIMEOUT);

        brackets.app.getNodeState(function (err, nodePort) {
            if (!err && nodePort && deferred.state() !== "rejected") {
                port = nodePort;
                ws = new WebSocket("ws://localhost:" + port);

                // Expect ArrayBuffer objects from Node when receiving binary
                // data instead of DOM Blobs, which are the default.
                ws.binaryType = "arraybuffer";

                // If the server port isn't open, we get a close event
                // at some point in the future (and will not get an onopen
                // event)
                ws.onclose = function () {
                    deferred.reject("WebSocket closed");
                };

                ws.onopen = function () {
                    // If we successfully opened, remove the old onclose
                    // handler (which was present to detect failure to
                    // connect at all).
                    ws.onclose = null;
                    deferred.resolveWith(null, [ws, port]);
                };
            } else {
                deferred.reject("brackets.app.getNodeState error: " + err);
            }
        });

        return deferred.promise();
    }
@private
Helper function to attempt a single connection to the node server