Home Explore Blog CI



neovim

47th chunk of `runtime/doc/luvref.txt`
5e3aabfabdb3be9a4b9993bb257e28bd98ce71d9d39e57bf0000000100000fa0

==============================================================================
DNS UTILITY FUNCTIONS                                *luv-dns-utility-functions*

uv.getaddrinfo({host}, {service} [, {hints} [, {callback}]])  *uv.getaddrinfo()*

                Parameters:
                - `host`: `string` or `nil`
                - `service`: `string` or `nil`
                - `hints`: `table` or `nil`
                  - `family`: `string` or `integer` or `nil`
                  - `socktype`: `string` or `integer` or `nil`
                  - `protocol`: `string` or `integer` or `nil`
                  - `addrconfig`: `boolean` or `nil`
                  - `v4mapped`: `boolean` or `nil`
                  - `all`: `boolean` or `nil`
                  - `numerichost`: `boolean` or `nil`
                  - `passive`: `boolean` or `nil`
                  - `numericserv`: `boolean` or `nil`
                  - `canonname`: `boolean` or `nil`
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
                  - `err`: `nil` or `string`
                  - `addresses`: `table` or `nil` (see below)

                Equivalent to `getaddrinfo(3)`. Either `node` or `service` may
                be `nil` but not both.

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

                See |luv-constants| for supported `socktype` input and
                output values.

                When `protocol` is set to `0` or `nil`, it will be
                automatically chosen based on the socket's domain and type.
                When `protocol` is specified as a string, it will be looked up
                using the `getprotobyname(3)` function. Examples: `"ip"`,
                `"icmp"`, `"tcp"`, `"udp"`, etc.

                Returns (sync version): `table` or `fail`
                - `[1, 2, 3, ..., n]` : `table`
                  - `addr` : `string`
                  - `family` : `string`
                  - `port` : `integer` or `nil`
                  - `socktype` : `string`
                  - `protocol` : `string`
                  - `canonname` : `string` or `nil`

                Returns (async version): `uv_getaddrinfo_t userdata` or `fail`

uv.getnameinfo({address} [, {callback}])                      *uv.getnameinfo()*

                Parameters:
                - `address`: `table`
                  - `ip`: `string` or `nil`
                  - `port`: `integer` or `nil`
                  - `family`: `string` or `integer` or `nil`
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
                  - `err`: `nil` or `string`
                  - `host`: `string` or `nil`
                  - `service`: `string` or `nil`

                Equivalent to `getnameinfo(3)`.

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

                Returns (sync version): `string, string` or `fail`

                Returns (async version): `uv_getnameinfo_t userdata` or `fail`

==============================================================================
THREADING AND SYNCHRONIZATION UTILITIES *luv-threading-and-synchronization-utilities*

Libuv provides cross-platform implementations for multiple threading and
synchronization primitives. The API largely follows the pthreads API.

uv.new_thread([{options}, ] {entry}, {...})                    *uv.new_thread()*

                Parameters:
                - `options`: `table` or `nil`
                  - `stack_size`: `integer` or `nil`
                - `entry`: `function` or `string`
                - `...`: `threadargs` passed to `entry`

                Creates and initializes a `luv_thread_t` (not `uv_thread_t`).
                Returns the Lua userdata wrapping it and asynchronously
                executes `entry`, which can be either a Lua function or a
                string containing Lua code or

Title: DNS Utility Functions and Threading/Synchronization Utilities
Summary
This section details the `uv.getaddrinfo` function for address resolution and `uv.getnameinfo` for reverse address resolution. It also introduces Libuv's cross-platform threading and synchronization primitives, specifically `uv.new_thread` for creating and initializing threads with optional stack size configuration and Lua code execution.