You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
socket.connect() is described as accepting the following option:
onread {Object} If specified, incoming data is stored in a single buffer
and passed to the supplied callback when data arrives on the socket.
This will cause the streaming functionality to not provide any data.
The socket will emit events like 'error', 'end', and 'close'
as usual. Methods like pause() and resume() will also behave as
expected.
buffer {Buffer|Uint8Array|Function} Either a reusable chunk of memory to
use for storing incoming data or a function that returns such.
callback {Function} This function is called for every chunk of incoming
data. Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer. Return false from this function to
implicitly pause() the socket. This function will be executed in the
global context.
However, this is not correct, and is actually accepted only in the Socket() constructor:
The example given using net.connect() is still correct because the options "Will be passed to both the new net.Socket([options]) call and the socket.connect(options[, connectListener]) method."
The example given using net.connect() is still correct because the options "Will be passed to both the new net.Socket([options]) call and the socket.connect(options[, connectListener]) method."
@lights0123 yes, it's still correct because net.connect(options[, connectListener]) create an instance of Socket(options) when it called
I think a solution can be to move this function description to Socket class and mention on the net.connect(options[, connectListener]) part it's can be possible to use same onread object from Socket class constructor. Right ? @redyetidev what do you think about it ?
Activity
avivkeller commentedon Jul 9, 2024
Thanks for the report! If you have an improvement, feel free to submit a PR!
eliphazbouye commentedon Jul 18, 2024
@lights0123 yes, it's still correct because
net.connect(options[, connectListener])create an instance ofSocket(options)when it callednode/lib/net.js
Line 227 in b4e8f1b
I think a solution can be to move this function description to Socket class and mention on the
net.connect(options[, connectListener])part it's can be possible to use sameonreadobject from Socket class constructor. Right ? @redyetidev what do you think about it ?doc: move `onread` option from `socket.connect()` to `new net.socket()`
doc: move `net.connect()` function example to suitable section
doc: move `onread` option from `socket.connect()` to `new net.socket()`
doc: move `onread` option from `socket.connect()` to `new net.socket()`
doc: move `onread` option from `socket.connect()` to `new net.socket()`
doc: move `onread` option from `socket.connect()` to `new net.socket()`