From 916e057feab485d05888f94b00dd0fe8753753b5 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 18 Mar 2010 14:33:42 -0700 Subject: [PATCH] Add 'opening' readyState --- lib/net.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/net.js b/lib/net.js index 77949e0fc8..ed746790d1 100644 --- a/lib/net.js +++ b/lib/net.js @@ -4,10 +4,8 @@ var events = require("events"); var debugLevel = 0; if ('NODE_DEBUG' in process.ENV) debugLevel = 1; -function debug (x) { - if (debugLevel > 0) { - process.stdio.writeError(x + '\n'); - } +function debug () { + if (debugLevel > 0) sys.error.apply(this, arguments); } var binding = process.binding('net'); @@ -400,7 +398,9 @@ Object.defineProperty(Stream.prototype, 'readyState', { readyStateMessage = 'readyState is depricated. Use stream.readable or stream.writable'; sys.error(readyStateMessage); } - if (this.readable && this.writable) { + if (this._resolving) { + return 'opening'; + } else if (this.readable && this.writable) { return 'open'; } else if (this.readable && !this.writable){ return 'readOnly'; @@ -658,7 +658,9 @@ Stream.prototype.connect = function () { self.type = 'tcp'; // TODO dns resolution on arguments[1] var port = arguments[0]; + self._resolving = true; lookupDomainName(arguments[1], function (ip) { + self._resolving = false; doConnect(self, port, ip); }); } else {