net: add new options to `net.Socket` and `net.Server`
Hello!
This PR adds the new following options to net.Socket.connect
:
-
noDelay
(boolean): If set totrue
, callsuv_tcp_nodelay
on the socket after connection. By default it is disabled. -
keepAlive
(boolean) andkeepAliveDelay
(number): If set totrue
callsuv_tcp_nodelay
on the socket after connection. By default it is disabled.
This changes are needed as preliminary work on #34185 (closed) to avoid excessive JS to C++ bridging. As I'm not a C++ expert, I encountered the following problems:
- Not sure how to test changes (even though test suite is passing so apparently nothing is broken)
- Error handling in
TCPWrap::AfterConnect
was tentative so some C++ expert should take a look. Moreover, what shall we do ifuv_tcp_connect
succeeds but any ofuv_tcp_nodelay
oruv_tcp_keepalive
fails? Shall we close the socket or let user handle it? Currently I don't do anything.
Once this is initially reviewed, I will also add (either here or in a new PR) the analogous on inbound connections.