Home Explore Blog CI



neovim

31th chunk of `runtime/doc/luvref.txt`
711fa80c14dba57228d6fd14fa1658e99bb9d06b4d8ff71f0000000100000fa2
 return
                value is `"supported"` or `"unsupported"`.

                This function is not implemented on Unix, where it returns
                `ENOTSUP`.

                Returns: `string` or `fail`

==============================================================================
`uv_udp_t` — UDP handle                                  *luv-udp-handle* *uv_udp_t*

> |uv_handle_t| functions also apply.

UDP handles encapsulate UDP communication for both clients and servers.

uv.new_udp([{flags}])                                             *uv.new_udp()*

                Parameters:
                - `flags`: `table` or `nil`
                  - `family`: `string` or `nil`
                  - `mmsgs`: `integer` or `nil` (default: `1`)

                Creates and initializes a new |uv_udp_t|. Returns the Lua
                userdata wrapping it. The actual socket is created lazily.

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

                When specified, `mmsgs` determines the number of messages able
                to be received at one time via `recvmmsg(2)` (the allocated
                buffer will be sized to be able to fit the specified number of
                max size dgrams). Only has an effect on platforms that support
                `recvmmsg(2)`.

                Note: For backwards compatibility reasons, `flags` can also be
                a string or integer. When it is a string, it will be treated
                like the `family` key above. When it is an integer, it will be
                used directly as the `flags` parameter when calling
                `uv_udp_init_ex`.

                Returns: `uv_udp_t userdata` or `fail`

uv.udp_get_send_queue_size()                      *uv.udp_get_send_queue_size()*

                > method form `udp:get_send_queue_size()`

                Returns the handle's send queue size.

                Returns: `integer`

uv.udp_get_send_queue_count()                    *uv.udp_get_send_queue_count()*

                > method form `udp:get_send_queue_count()`

                Returns the handle's send queue count.

                Returns: `integer`

uv.udp_open({udp}, {fd})                                         *uv.udp_open()*

                > method form `udp:open(fd)`

                Parameters:
                - `udp`: `uv_udp_t userdata`
                - `fd`: `integer`

                Opens an existing file descriptor or Windows SOCKET as a UDP
                handle.

                Unix only: The only requirement of the sock argument is that
                it follows the datagram contract (works in unconnected mode,
                supports sendmsg()/recvmsg(), etc). In other words, other
                datagram-type sockets like raw sockets or netlink sockets can
                also be passed to this function.

                The file descriptor is set to non-blocking mode.

                Note: The passed file descriptor or SOCKET is not checked for
                its type, but it's required that it represents a valid
                datagram socket.

                Returns: `0` or `fail`

uv.udp_bind({udp}, {host}, {port} [, {flags}])                   *uv.udp_bind()*

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

                Parameters:
                - `udp`: `uv_udp_t userdata`
                - `host`: `string`
                - `port`: `number`
                - `flags`: `table` or `nil`
                  - `ipv6only`: `boolean`
                  - `reuseaddr`: `boolean`

                Bind the UDP handle to an IP address and port. Any `flags` are
                set with a table with fields `reuseaddr` or `ipv6only` equal
                to `true` or `false`.

                Returns: `0` or `fail`

uv.udp_getsockname({udp})                                 *uv.udp_getsockname()*

                > method form `udp:getsockname()`

                Parameters:
       

Title: Libuv UDP Functions: Creation, Binding, Queue Size, and Socket Operations
Summary
This section describes various functions for working with UDP sockets in libuv, including `uv.new_udp()` for creating a new UDP handle, `uv.udp_get_send_queue_size()` and `uv.udp_get_send_queue_count()` for retrieving the send queue status, `uv.udp_open()` for associating an existing file descriptor with a UDP handle, `uv.udp_bind()` for binding the handle to an IP address and port, and `uv.udp_getsockname()` to get the socket name.