@@ -52,6 +52,8 @@ This class is used to create a TCP or [IPC][] server.
52
52
53
53
## new net.Server([ options] [ , connectionListener ] )
54
54
55
+ * Returns: {net.Server}
56
+
55
57
See [ ` net.createServer([options][, connectionListener]) ` ] [ `net.createServer()` ] .
56
58
57
59
` net.Server ` is an [ ` EventEmitter ` ] [ ] with the following events:
@@ -130,13 +132,17 @@ Don't call `server.address()` until the `'listening'` event has been emitted.
130
132
added: v0.1.90
131
133
-->
132
134
135
+ * Returns: {net.Server}
136
+
133
137
Stops the server from accepting new connections and keeps existing
134
138
connections. This function is asynchronous, the server is finally
135
139
closed when all connections are ended and the server emits a [ ` 'close' ` ] [ ] event.
136
140
The optional ` callback ` will be called once the ` 'close' ` event occurs. Unlike
137
141
that event, it will be called with an Error as its only argument if the server
138
142
was not open when it was closed.
139
143
144
+ Returns ` server ` .
145
+
140
146
### server.connections
141
147
<!-- YAML
142
148
added: v0.2.0
@@ -218,6 +224,7 @@ added: v0.5.10
218
224
* ` handle ` {Object}
219
225
* ` backlog ` {number} Common parameter of [ ` server.listen() ` ] [ ] functions
220
226
* ` callback ` {Function} Common parameter of [ ` server.listen() ` ] [ ] functions
227
+ * Returns: {net.Server}
221
228
222
229
Start a server listening for connections on a given ` handle ` that has
223
230
already been bound to a port, a UNIX domain socket, or a Windows named pipe.
@@ -243,6 +250,7 @@ added: v0.11.14
243
250
* ` exclusive ` {boolean} Default to ` false `
244
251
* ` callback ` {Function} Common parameter of [ ` server.listen() ` ] [ ]
245
252
functions
253
+ * Returns: {net.Server}
246
254
247
255
If ` port ` is specified, it behaves the same as
248
256
[ ` server.listen([port][, hostname][, backlog][, callback]) ` ] [ `server.listen(port, host)` ] .
@@ -273,6 +281,7 @@ added: v0.1.90
273
281
[ Identifying paths for IPC connections] [ ] .
274
282
* ` backlog ` {number} Common parameter of [ ` server.listen() ` ] [ ] functions
275
283
* ` callback ` {Function} Common parameter of [ ` server.listen() ` ] [ ] functions
284
+ * Returns: {net.Server}
276
285
277
286
Start a [ IPC] [ ] server listening for connections on the given ` path ` .
278
287
@@ -284,6 +293,7 @@ added: v0.1.90
284
293
* ` host ` {string}
285
294
* ` backlog ` {number} Common parameter of [ ` server.listen() ` ] [ ] functions
286
295
* ` callback ` {Function} Common parameter of [ ` server.listen() ` ] [ ] functions
296
+ * Returns: {net.Server}
287
297
288
298
Start a TCP server listening for connections on the given ` port ` and ` host ` .
289
299
@@ -323,23 +333,23 @@ with [`child_process.fork()`][].
323
333
added: v0.9.1
324
334
-->
325
335
336
+ * Returns: {net.Server}
337
+
326
338
Opposite of ` unref ` , calling ` ref ` on a previously ` unref ` d server will * not*
327
339
let the program exit if it's the only server left (the default behavior). If
328
340
the server is ` ref ` d calling ` ref ` again will have no effect.
329
341
330
- Returns ` server ` .
331
-
332
342
### server.unref()
333
343
<!-- YAML
334
344
added: v0.9.1
335
345
-->
336
346
347
+ * Returns: {net.Server}
348
+
337
349
Calling ` unref ` on a server will allow the program to exit if this is the only
338
350
active server in the event system. If the server is already ` unref ` d calling
339
351
` unref ` again will have no effect.
340
352
341
- Returns ` server ` .
342
-
343
353
## Class: net.Socket
344
354
<!-- YAML
345
355
added: v0.3.4
@@ -532,6 +542,7 @@ Possible signatures:
532
542
for [ IPC] [ ] connections.
533
543
* [ socket.connect(port[ , host] [ , connectListener ] )] [ `socket.connect(port, host)` ]
534
544
for TCP connections.
545
+ * Returns: {net.Socket} The socket itself.
535
546
536
547
This function is asynchronous. When the connection is established, the
537
548
[ ` 'connect' ` ] [ ] event will be emitted. If there is a problem connecting,
@@ -578,6 +589,8 @@ For [IPC][] connections, available `options` are:
578
589
* ` path ` {string} Required. Path the client should connect to.
579
590
See [ Identifying paths for IPC connections] [ ] .
580
591
592
+ Returns ` socket ` .
593
+
581
594
#### socket.connect(path[ , connectListener] )
582
595
583
596
* ` path ` {string} Path the client should connect to. See
@@ -592,6 +605,8 @@ Alias to
592
605
[ ` socket.connect(options[, connectListener]) ` ] [ `socket.connect(options)` ]
593
606
called with ` { path: path } ` as ` options ` .
594
607
608
+ Returns ` socket ` .
609
+
595
610
#### socket.connect(port[ , host] [ , connectListener ] )
596
611
<!-- YAML
597
612
added: v0.1.90
@@ -609,6 +624,8 @@ Alias to
609
624
[ ` socket.connect(options[, connectListener]) ` ] [ `socket.connect(options)` ]
610
625
called with ` {port: port, host: host} ` as ` options ` .
611
626
627
+ Returns ` socket ` .
628
+
612
629
### socket.connecting
613
630
<!-- YAML
614
631
added: v6.1.0
@@ -642,14 +659,14 @@ connection is destroyed no further data can be transferred using it.
642
659
added: v0.1.90
643
660
-->
644
661
662
+ * Returns: {net.Socket} The socket itself.
663
+
645
664
Half-closes the socket. i.e., it sends a FIN packet. It is possible the
646
665
server will still send some data.
647
666
648
667
If ` data ` is specified, it is equivalent to calling
649
668
` socket.write(data, encoding) ` followed by [ ` socket.end() ` ] [ ] .
650
669
651
- Returns ` socket ` .
652
-
653
670
### socket.localAddress
654
671
<!-- YAML
655
672
added: v0.9.6
@@ -670,6 +687,8 @@ The numeric representation of the local port. For example,
670
687
671
688
### socket.pause()
672
689
690
+ * Returns: {net.Socket} The socket itself.
691
+
673
692
Pauses the reading of data. That is, [ ` 'data' ` ] [ ] events will not be emitted.
674
693
Useful to throttle back an upload.
675
694
@@ -678,12 +697,12 @@ Useful to throttle back an upload.
678
697
added: v0.9.1
679
698
-->
680
699
700
+ * Returns: {net.Socket} The socket itself.
701
+
681
702
Opposite of ` unref ` , calling ` ref ` on a previously ` unref ` d socket will * not*
682
703
let the program exit if it's the only socket left (the default behavior). If
683
704
the socket is ` ref ` d calling ` ref ` again will have no effect.
684
705
685
- Returns ` socket ` .
686
-
687
706
### socket.remoteAddress
688
707
<!-- YAML
689
708
added: v0.5.10
@@ -710,13 +729,17 @@ The numeric representation of the remote port. For example,
710
729
711
730
### socket.resume()
712
731
732
+ * Returns: {net.Socket} The socket itself.
733
+
713
734
Resumes reading after a call to [ ` socket.pause() ` ] [ ] .
714
735
715
736
### socket.setEncoding([ encoding] )
716
737
<!-- YAML
717
738
added: v0.1.90
718
739
-->
719
740
741
+ * Returns: {net.Socket} The socket itself.
742
+
720
743
Set the encoding for the socket as a [ Readable Stream] [ ] . See
721
744
[ ` stream.setEncoding() ` ] [ ] for more information.
722
745
@@ -725,6 +748,8 @@ Set the encoding for the socket as a [Readable Stream][]. See
725
748
added: v0.1.92
726
749
-->
727
750
751
+ * Returns: {net.Socket} The socket itself.
752
+
728
753
Enable/disable keep-alive functionality, and optionally set the initial
729
754
delay before the first keepalive probe is sent on an idle socket.
730
755
` enable ` defaults to ` false ` .
@@ -734,25 +759,25 @@ data packet received and the first keepalive probe. Setting 0 for
734
759
initialDelay will leave the value unchanged from the default
735
760
(or previous) setting. Defaults to ` 0 ` .
736
761
737
- Returns ` socket ` .
738
-
739
762
### socket.setNoDelay([ noDelay] )
740
763
<!-- YAML
741
764
added: v0.1.90
742
765
-->
743
766
767
+ * Returns: {net.Socket} The socket itself.
768
+
744
769
Disables the Nagle algorithm. By default TCP connections use the Nagle
745
770
algorithm, they buffer data before sending it off. Setting ` true ` for
746
771
` noDelay ` will immediately fire off data each time ` socket.write() ` is called.
747
772
` noDelay ` defaults to ` true ` .
748
773
749
- Returns ` socket ` .
750
-
751
774
### socket.setTimeout(timeout[ , callback] )
752
775
<!-- YAML
753
776
added: v0.1.90
754
777
-->
755
778
779
+ * Returns: {net.Socket} The socket itself.
780
+
756
781
Sets the socket to timeout after ` timeout ` milliseconds of inactivity on
757
782
the socket. By default ` net.Socket ` do not have a timeout.
758
783
@@ -773,19 +798,17 @@ If `timeout` is 0, then the existing idle timeout is disabled.
773
798
The optional ` callback ` parameter will be added as a one time listener for the
774
799
[ ` 'timeout' ` ] [ ] event.
775
800
776
- Returns ` socket ` .
777
-
778
801
### socket.unref()
779
802
<!-- YAML
780
803
added: v0.9.1
781
804
-->
782
805
806
+ * Returns: {net.Socket} The socket itself.
807
+
783
808
Calling ` unref ` on a socket will allow the program to exit if this is the only
784
809
active socket in the event system. If the socket is already ` unref ` d calling
785
810
` unref ` again will have no effect.
786
811
787
- Returns ` socket ` .
788
-
789
812
### socket.write(data[ , encoding] [ , callback ] )
790
813
<!-- YAML
791
814
added: v0.1.90
@@ -965,6 +988,7 @@ Creates a new TCP or [IPC][] server.
965
988
should be paused on incoming connections.
966
989
* ` connectionListener ` {Function} Automatically set as a listener for the
967
990
[ ` 'connection' ` ] [ ] event
991
+ * Returns: {net.Server}
968
992
969
993
If ` allowHalfOpen ` is set to ` true ` , when the other end of the socket
970
994
sends a FIN packet, the server will only send a FIN packet back when
0 commit comments