High Water Mark for Client #4580
Replies: 2 comments
|
You're correct that Why Isn’t
|
|
I think the client side can already be configured, although this is not very obvious from the net.Socket documentation. net.createConnection(options) passes the options object to new net.Socket(options), and net.Socket forwards those options to the underlying Duplex constructor. So something like this should work: const socket = net.createConnection({ Or, if different values are desired for each side of the Duplex stream: const socket = net.createConnection({ The reason createServer has an explicit highWaterMark option seems to be that the server creates the accepted net.Socket instances internally, so the caller otherwise has no constructor options to provide for those sockets. For an outgoing connection, the caller is already supplying the options used to construct the Socket. It is also worth distinguishing the stream highWaterMark from the operating system TCP send/receive buffer sizes. highWaterMark is primarily a Node.js stream backpressure/buffering threshold. It is not the TCP socket buffer size itself, and the values do not necessarily need to match on both ends of a TCP connection. One thing that may be worth improving here is the documentation, since net.Socket does not make the inherited Duplex highWaterMark options especially obvious. |
Uh oh!
There was an error while loading. Please reload this page.
In Node Net Sockets, the server can pass along a highWaterMark to set write and read sizes. A client can't do this. It creates an issue when attempting to match buffer sizes from one side to the other. A client creation only takes the default low 16MB size currently. Is there a reason we don't allow clients to set sizes and only have this option in the create server for a socket?
Thanks!
All reactions