diff options
Diffstat (limited to 'lib/net.js')
-rw-r--r-- | lib/net.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/net.js b/lib/net.js index 005f339c28..34de98bc3c 100644 --- a/lib/net.js +++ b/lib/net.js @@ -180,8 +180,16 @@ function Socket(options) { // if we have a handle, then start the flow of data into the // buffer. if not, then this will happen when we connect - if (this._handle && options.readable !== false) - this.read(0); + if (this._handle && options.readable !== false) { + if (options.pauseOnCreate) { + // stop the handle from reading and pause the stream + this._handle.reading = false; + this._handle.readStop(); + this._readableState.flowing = false; + } else { + this.read(0); + } + } } util.inherits(Socket, stream.Duplex); @@ -1024,6 +1032,7 @@ function Server(/* [ options, ] listener */) { this._slaves = []; this.allowHalfOpen = options.allowHalfOpen || false; + this.pauseOnConnect = !!options.pauseOnConnect; } util.inherits(Server, events.EventEmitter); exports.Server = Server; @@ -1287,7 +1296,8 @@ function onconnection(err, clientHandle) { var socket = new Socket({ handle: clientHandle, - allowHalfOpen: self.allowHalfOpen + allowHalfOpen: self.allowHalfOpen, + pauseOnCreate: self.pauseOnConnect }); socket.readable = socket.writable = true; |