@@ -130,7 +130,7 @@ as a string.
130130const server = net .createServer ((socket ) => {
131131 socket .end (' goodbye\n ' );
132132}).on (' error' , (err ) => {
133- // handle errors here
133+ // Handle errors here.
134134 throw err;
135135});
136136
@@ -147,7 +147,7 @@ Don't call `server.address()` until the `'listening'` event has been emitted.
147147added: v0.1.90
148148-->
149149
150- * ` callback ` {Function} Called when the server is closed
150+ * ` callback ` {Function} Called when the server is closed.
151151* Returns: {net.Server}
152152
153153Stops the server from accepting new connections and keeps existing
@@ -165,6 +165,8 @@ deprecated: v0.9.7
165165
166166> Stability: 0 - Deprecated: Use [ ` server.getConnections() ` ] [ ] instead.
167167
168+ * {integer|null}
169+
168170The number of concurrent connections on the server.
169171
170172This becomes ` null ` when sending a socket to a child with
@@ -269,9 +271,9 @@ changes:
269271 functions.
270272 * ` exclusive ` {boolean} ** Default:** ` false `
271273 * ` readableAll ` {boolean} For IPC servers makes the pipe readable
272- for all users. ** Default:** ` false `
274+ for all users. ** Default:** ` false ` .
273275 * ` writableAll ` {boolean} For IPC servers makes the pipe writable
274- for all users. ** Default:** ` false `
276+ for all users. ** Default:** ` false ` .
275277 * ` ipv6Only ` {boolean} For TCP servers, setting ` ipv6Only ` to ` true ` will
276278 disable dual-stack support, i.e., binding to host ` :: ` won't make
277279 ` 0.0.0.0 ` be bound. ** Default:** ` false ` .
@@ -354,6 +356,8 @@ added: v5.7.0
354356added: v0.2.0
355357-->
356358
359+ * {integer}
360+
357361Set this property to reject connections when the server's connection count gets
358362high.
359363
@@ -542,6 +546,8 @@ socket as reported by the operating system:
542546added: v0.3.8
543547-->
544548
549+ * {integer}
550+
545551` net.Socket ` has the property that ` socket.write() ` always works. This is to
546552help users get up and running quickly. The computer cannot always keep up
547553with the amount of data that is written to a socket - the network connection
@@ -564,13 +570,17 @@ Users who experience large or growing `bufferSize` should attempt to
564570added: v0.5.3
565571-->
566572
573+ * {integer}
574+
567575The amount of received bytes.
568576
569577### socket.bytesWritten
570578<!-- YAML
571579added: v0.5.3
572580-->
573581
582+ * {integer}
583+
574584The amount of bytes sent.
575585
576586### socket.connect()
@@ -659,10 +669,10 @@ const net = require('net');
659669net .connect ({
660670 port: 80 ,
661671 onread: {
662- // Reuses a 4KiB Buffer for every read from the socket
672+ // Reuses a 4KiB Buffer for every read from the socket.
663673 buffer: Buffer .alloc (4 * 1024 ),
664674 callback : function (nread , buf ) {
665- // Received data is available in `buf` from 0 to `nread`
675+ // Received data is available in `buf` from 0 to `nread`.
666676 console .log (buf .toString (' utf8' , 0 , nread));
667677 }
668678 }
@@ -705,6 +715,8 @@ called with `{port: port, host: host}` as `options`.
705715added: v6.1.0
706716-->
707717
718+ * {boolean}
719+
708720If ` true ` ,
709721[ ` socket.connect(options[, connectListener]) ` ] [ `socket.connect(options)` ] was
710722called and has not yet finished. It will stay ` true ` until the socket becomes
@@ -732,7 +744,7 @@ listeners for that event will receive `exception` as an argument.
732744* {boolean} Indicates if the connection is destroyed or not. Once a
733745 connection is destroyed no further data can be transferred using it.
734746
735- ### socket.end([ data] [ , encoding ] [ , callback] )
747+ ### socket.end([ data[ , encoding] ][ , callback ] )
736748<!-- YAML
737749added: v0.1.90
738750-->
@@ -753,6 +765,8 @@ If `data` is specified, it is equivalent to calling
753765added: v0.9.6
754766-->
755767
768+ * {string}
769+
756770The string representation of the local IP address the remote client is
757771connecting on. For example, in a server listening on ` '0.0.0.0' ` , if a client
758772connects on ` '192.168.1.1' ` , the value of ` socket.localAddress ` would be
@@ -763,6 +777,8 @@ connects on `'192.168.1.1'`, the value of `socket.localAddress` would be
763777added: v0.9.6
764778-->
765779
780+ * {integer}
781+
766782The numeric representation of the local port. For example, ` 80 ` or ` 21 ` .
767783
768784### socket.pause()
@@ -799,6 +815,8 @@ If the socket is `ref`ed calling `ref` again will have no effect.
799815added: v0.5.10
800816-->
801817
818+ * {string}
819+
802820The string representation of the remote IP address. For example,
803821` '74.125.127.100' ` or ` '2001:4860:a005::68' ` . Value may be ` undefined ` if
804822the socket is destroyed (for example, if the client disconnected).
@@ -808,13 +826,17 @@ the socket is destroyed (for example, if the client disconnected).
808826added: v0.11.14
809827-->
810828
829+ * {string}
830+
811831The string representation of the remote IP family. ` 'IPv4' ` or ` 'IPv6' ` .
812832
813833### socket.remotePort
814834<!-- YAML
815835added: v0.5.10
816836-->
817837
838+ * {integer}
839+
818840The numeric representation of the remote port. For example, ` 80 ` or ` 21 ` .
819841
820842### socket.resume()
@@ -946,6 +968,7 @@ added: v0.7.0
946968
947969* ` options ` {Object}
948970* ` connectListener ` {Function}
971+ * Returns: {net.Socket}
949972
950973Alias to
951974[ ` net.createConnection(options[, connectListener]) ` ] [ `net.createConnection(options)` ] .
@@ -957,6 +980,7 @@ added: v0.1.90
957980
958981* ` path ` {string}
959982* ` connectListener ` {Function}
983+ * Returns: {net.Socket}
960984
961985Alias to
962986[ ` net.createConnection(path[, connectListener]) ` ] [ `net.createConnection(path)` ] .
@@ -969,6 +993,7 @@ added: v0.1.90
969993* ` port ` {number}
970994* ` host ` {string}
971995* ` connectListener ` {Function}
996+ * Returns: {net.Socket}
972997
973998Alias to
974999[ ` net.createConnection(port[, host][, connectListener]) ` ] [ `net.createConnection(port, host)` ] .
@@ -1023,7 +1048,7 @@ in the [`net.createServer()`][] section:
10231048``` js
10241049const net = require (' net' );
10251050const client = net .createConnection ({ port: 8124 }, () => {
1026- // 'connect' listener
1051+ // 'connect' listener.
10271052 console .log (' connected to server!' );
10281053 client .write (' world!\r\n ' );
10291054});
@@ -1077,7 +1102,7 @@ added: v0.1.90
10771102* ` connectListener ` {Function} Common parameter of the
10781103 [ ` net.createConnection() ` ] [ ] functions, an "once" listener for the
10791104 ` 'connect' ` event on the initiating socket. Will be passed to
1080- [ ` socket.connect(path [, connectListener]) ` ] [ `socket.connect(port, host)` ] .
1105+ [ ` socket.connect(port[, host] [, connectListener]) ` ] [ `socket.connect(port, host)` ] .
10811106* Returns: {net.Socket} The newly created socket used to start the connection.
10821107
10831108Initiates a TCP connection.
@@ -1124,7 +1149,7 @@ on port 8124:
11241149``` js
11251150const net = require (' net' );
11261151const server = net .createServer ((c ) => {
1127- // 'connection' listener
1152+ // 'connection' listener.
11281153 console .log (' client connected' );
11291154 c .on (' end' , () => {
11301155 console .log (' client disconnected' );
@@ -1193,6 +1218,9 @@ added: v0.3.0
11931218
11941219Returns ` true ` if input is a version 6 IP address, otherwise returns ` false ` .
11951220
1221+ [ IPC ] : #net_ipc_support
1222+ [ Identifying paths for IPC connections ] : #net_identifying_paths_for_ipc_connections
1223+ [ Readable Stream ] : stream.html#stream_class_stream_readable
11961224[ `'close'` ] : #net_event_close
11971225[ `'connect'` ] : #net_event_connect
11981226[ `'connection'` ] : #net_event_connection
@@ -1238,9 +1266,6 @@ Returns `true` if input is a version 6 IP address, otherwise returns `false`.
12381266[ `socket.setEncoding()` ] : #net_socket_setencoding_encoding
12391267[ `socket.setTimeout()` ] : #net_socket_settimeout_timeout_callback
12401268[ `socket.setTimeout(timeout)` ] : #net_socket_settimeout_timeout_callback
1241- [ IPC ] : #net_ipc_support
1242- [ Identifying paths for IPC connections ] : #net_identifying_paths_for_ipc_connections
1243- [ Readable Stream ] : stream.html#stream_class_stream_readable
12441269[ half-closed ] : https://tools.ietf.org/html/rfc1122
12451270[ stream_writable_write ] : stream.html#stream_writable_write_chunk_encoding_callback
12461271[ unspecified IPv4 address ] : https://en.wikipedia.org/wiki/0.0.0.0
0 commit comments