active socket in the event system. If the socket is already `unref`d calling
`unref` again will have no effect.
+Returns `socket`.
+
### socket.ref()
Opposite of `unref`, calling `ref` on a previously `unref`d socket will *not*
let the program exit if it's the only socket left (the default behavior). If
the socket is `ref`d calling `ref` again will have no effect.
+
+Returns `socket`.
active server in the event system. If the server is already `unref`d calling
`unref` again will have no effect.
+Returns `server`.
+
### server.ref()
Opposite of `unref`, calling `ref` on a previously `unref`d server will *not*
let the program exit if it's the only server left (the default behavior). If
the server is `ref`d calling `ref` again will have no effect.
+Returns `server`.
+
### server.maxConnections
Set this property to reject connections when the server's connection count gets
active socket in the event system. If the socket is already `unref`d calling
`unref` again will have no effect.
+Returns `socket`.
+
### socket.ref()
Opposite of `unref`, calling `ref` on a previously `unref`d socket will *not*
let the program exit if it's the only socket left (the default behavior). If
the socket is `ref`d calling `ref` again will have no effect.
+Returns `socket`.
+
### socket.remoteAddress
The string representation of the remote IP address. For example,
Socket.prototype.ref = function() {
if (this._handle)
this._handle.ref();
+
+ return this;
};
Socket.prototype.unref = function() {
if (this._handle)
this._handle.unref();
+
+ return this;
};
Socket.prototype.ref = function() {
if (!this._handle) {
this.once('connect', this.ref);
- return;
+ return this;
}
this._handle.ref();
+
+ return this;
};
Socket.prototype.unref = function() {
if (!this._handle) {
this.once('connect', this.unref);
- return;
+ return this;
}
this._handle.unref();
+
+ return this;
};
if (this._handle)
this._handle.ref();
+
+ return this;
};
Server.prototype.unref = function() {
if (this._handle)
this._handle.unref();
+
+ return this;
};
--- /dev/null
+'use strict';
+var assert = require('assert');
+var net = require('net');
+var dgram = require('dgram');
+var common = require('../common');
+
+assert.ok((new net.Server()).ref() instanceof net.Server);
+assert.ok((new net.Server()).unref() instanceof net.Server);
+assert.ok((new net.Socket()).ref() instanceof net.Socket);
+assert.ok((new net.Socket()).unref() instanceof net.Socket);
+assert.ok((new dgram.Socket('udp4')).ref() instanceof dgram.Socket);
+assert.ok((new dgram.Socket('udp6')).unref() instanceof dgram.Socket);