Home Explore Blog CI



neovim

24th chunk of `runtime/doc/luvref.txt`
29f554905cecdad02fef226061ded68f561a9060831ad1d70000000100000fa0
 *uv.tcp_nodelay()*

                > method form `tcp:nodelay(enable)`

                Parameters:
                - `tcp`: `uv_tcp_t userdata`
                - `enable`: `boolean`

                Enable / disable Nagle's algorithm.

                Returns: `0` or `fail`

uv.tcp_keepalive({tcp}, {enable} [, {delay}])               *uv.tcp_keepalive()*

                > method form `tcp:keepalive(enable, [delay])`

                Parameters:
                - `tcp`: `uv_tcp_t userdata`
                - `enable`: `boolean`
                - `delay`: `integer` or `nil`

                Enable / disable TCP keep-alive. `delay` is the initial delay
                in seconds, ignored when enable is `false`.

                Returns: `0` or `fail`

uv.tcp_simultaneous_accepts({tcp}, {enable})     *uv.tcp_simultaneous_accepts()*

                > method form `tcp:simultaneous_accepts(enable)`

                Parameters:
                - `tcp`: `uv_tcp_t userdata`
                - `enable`: `boolean`

                Enable / disable simultaneous asynchronous accept requests
                that are queued by the operating system when listening for new
                TCP connections.

                This setting is used to tune a TCP server for the desired
                performance. Having simultaneous accepts can significantly
                improve the rate of accepting connections (which is why it is
                enabled by default) but may lead to uneven load distribution
                in multi-process setups.

                Returns: `0` or `fail`

uv.tcp_bind({tcp}, {host}, {port} [, {flags}])                   *uv.tcp_bind()*

                > method form `tcp:bind(host, port, [flags])`

                Parameters:
                - `tcp`: `uv_tcp_t userdata`
                - `host`: `string`
                - `port`: `integer`
                - `flags`: `table` or `nil`
                  - `ipv6only`: `boolean`

                Bind the handle to an host and port. `host` should be an IP
                address and not a domain name. Any `flags` are set with a
                table with field `ipv6only` equal to `true` or `false`.

                When the port is already taken, you can expect to see an
                `EADDRINUSE` error from either `uv.tcp_bind()`, |uv.listen()|
                or |uv.tcp_connect()|. That is, a successful call to this
                function does not guarantee that the call to |uv.listen()| or
                |uv.tcp_connect()| will succeed as well.

                Use a port of `0` to let the OS assign an ephemeral port.  You
                can look it up later using |uv.tcp_getsockname()|.

                Returns: `0` or `fail`

uv.tcp_getpeername({tcp})                                 *uv.tcp_getpeername()*

                > method form `tcp:getpeername()`

                Parameters:
                - `tcp`: `uv_tcp_t userdata`

                Get the address of the peer connected to the handle.

                See |luv-constants| for supported address `family` output values.

                Returns: `table` or `fail`
                - `ip` : `string`
                - `family` : `string`
                - `port` : `integer`

uv.tcp_getsockname({tcp})                                 *uv.tcp_getsockname()*

                > method form `tcp:getsockname()`

                Parameters:
                - `tcp`: `uv_tcp_t userdata`

                Get the current address to which the handle is bound.

                See |luv-constants| for supported address `family` output values.

                Returns: `table` or `fail`
                - `ip` : `string`
                - `family` : `string`
                - `port` : `integer`

uv.tcp_connect({tcp}, {host}, {port}, {callback})             *uv.tcp_connect()*

                > method form `tcp:connect(host, port, callback)`

                Parameters:
                - `tcp`: `uv_tcp_t userdata`
        

Title: Libuv TCP Handle Functions: Configuration, Binding, and Connection
Summary
This section details several libuv TCP handle functions. It covers `uv.tcp_nodelay()` to enable/disable Nagle's algorithm, `uv.tcp_keepalive()` to manage TCP keep-alive settings (with an optional delay), and `uv.tcp_simultaneous_accepts()` to enable/disable simultaneous asynchronous accept requests for new TCP connections. It also explains `uv.tcp_bind()` to bind a TCP handle to a host and port, `uv.tcp_getpeername()` to retrieve the address of the peer connected to the handle, `uv.tcp_getsockname()` to get the current address the handle is bound to, and `uv.tcp_connect()` for initiating a TCP connection to a specified host and port with a callback.