Browse Source

Add 'opening' readyState

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
916e057fea
  1. 12
      lib/net.js

12
lib/net.js

@ -4,10 +4,8 @@ var events = require("events");
var debugLevel = 0; var debugLevel = 0;
if ('NODE_DEBUG' in process.ENV) debugLevel = 1; if ('NODE_DEBUG' in process.ENV) debugLevel = 1;
function debug (x) { function debug () {
if (debugLevel > 0) { if (debugLevel > 0) sys.error.apply(this, arguments);
process.stdio.writeError(x + '\n');
}
} }
var binding = process.binding('net'); var binding = process.binding('net');
@ -400,7 +398,9 @@ Object.defineProperty(Stream.prototype, 'readyState', {
readyStateMessage = 'readyState is depricated. Use stream.readable or stream.writable'; readyStateMessage = 'readyState is depricated. Use stream.readable or stream.writable';
sys.error(readyStateMessage); sys.error(readyStateMessage);
} }
if (this.readable && this.writable) { if (this._resolving) {
return 'opening';
} else if (this.readable && this.writable) {
return 'open'; return 'open';
} else if (this.readable && !this.writable){ } else if (this.readable && !this.writable){
return 'readOnly'; return 'readOnly';
@ -658,7 +658,9 @@ Stream.prototype.connect = function () {
self.type = 'tcp'; self.type = 'tcp';
// TODO dns resolution on arguments[1] // TODO dns resolution on arguments[1]
var port = arguments[0]; var port = arguments[0];
self._resolving = true;
lookupDomainName(arguments[1], function (ip) { lookupDomainName(arguments[1], function (ip) {
self._resolving = false;
doConnect(self, port, ip); doConnect(self, port, ip);
}); });
} else { } else {

Loading…
Cancel
Save