diff options
author | koichik <koichik@improvement.jp> | 2011-06-21 23:53:02 +0900 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-06-28 13:36:45 +0200 |
commit | 6c121edc6008ad502317b7a3c12e8a78b92217c7 (patch) | |
tree | 4d4cb4b4a411410481f6a4aba2d6d219c16b2445 /lib | |
parent | c626f8bd8faad80c5e9c4b77aa3f2ee32e25de68 (diff) | |
download | android-node-v8-6c121edc6008ad502317b7a3c12e8a78b92217c7.tar.gz android-node-v8-6c121edc6008ad502317b7a3c12e8a78b92217c7.tar.bz2 android-node-v8-6c121edc6008ad502317b7a3c12e8a78b92217c7.zip |
Fix mismatch createConnection and Socket.connect
net.createConnection() is wrapper for net.Socket.connect(),
but There is mismatch between them.
net.createConnection(port, [host])
net.Socket.connect(port, [host], [callback])
Fixes #1208.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net_legacy.js | 4 | ||||
-rw-r--r-- | lib/net_uv.js | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/net_legacy.js b/lib/net_legacy.js index 826d69f4ae..941c80eb3d 100644 --- a/lib/net_legacy.js +++ b/lib/net_legacy.js @@ -261,9 +261,9 @@ Socket.prototype.open = function(fd, type) { }; -exports.createConnection = function(port, host) { +exports.createConnection = function(port, host, callback) { var s = new Socket(); - s.connect(port, host); + s.connect(port, host, callback); return s; }; diff --git a/lib/net_uv.js b/lib/net_uv.js index f8ef412b36..f13322d6d4 100644 --- a/lib/net_uv.js +++ b/lib/net_uv.js @@ -24,9 +24,9 @@ exports.createServer = function() { }; -exports.connect = exports.createConnection = function(port, host) { +exports.connect = exports.createConnection = function(port, host /* [cb] */ ) { var s = new Socket(); - s.connect(port, host); + s.connect(port, host, arguments[2]); return s; }; @@ -284,9 +284,13 @@ function afterWrite(status, handle, req, buffer) { } -Socket.prototype.connect = function(port, host) { +Socket.prototype.connect = function(port, host /* [cb] */) { var self = this; + if (typeof arguments[2] === 'function') { + self.on('connect', arguments[2]); + } + timers.active(this); require('dns').lookup(host, function(err, ip, addressType) { |