`net.Stream` instances are EventEmitters with the following events:
-#### stream.connect(port, [host])
-#### stream.connect(path)
+#### stream.connect(port, [host], [callback])
+#### stream.connect(path, [callback])
Opens the connection for a given stream. If `port` and `host` are given,
then the stream will be opened as a TCP stream, if `host` is omitted,
event will not be emitted, the `'error'` event will be emitted with
the exception.
+The `callback` paramenter will be added as an listener for the 'connect'
+event.
+
#### stream.setEncoding(encoding=null)
self._connecting = true; // set false in doConnect
self.writable = true;
+ var lastArg = arguments[arguments.length - 1];
+ if (typeof lastArg == 'function') {
+ self.addListener('connect', lastArg);
+ }
+
var port = toPort(arguments[0]);
if (port === false) {
// UNIX
console.log('Connecting to socket');
- socket.connect(tcpPort);
-
-
- socket.on('connect', function() {
+ socket.connect(tcpPort, function() {
console.log('socket connected');
connectHappened = true;
});