nvim_runtime_lua

uv.uv_handle_t

supers: userdata

uv_handle_t - Base handle

uv_handle_t is the base type for all libuv handle types. All API functions defined here work with any handle type.

Methods10

function uv_handle_t.is_active() -> (active nil | boolean, err nil | string, err_name uv.error_name | nil)

Returns true if the handle is active, false if it's inactive. What "active” means depends on the type of handle:

  • A [uv_async_t][] handle is always active and cannot be deactivated, except
  • by closing it with uv.close().

  • A [uv_pipe_t][], [uv_tcp_t][], [uv_udp_t][], etc. handle - basically
  • any handle that deals with I/O - is active when it is doing something that involves I/O, like reading, writing, connecting, accepting new connections, etc.

  • A [uv_check_t][], [uv_idle_t][], [uv_timer_t][], etc. handle is active
  • when it has been started with a call to uv.check_start(), uv.idle_start(), uv.timer_start() etc. until it has been stopped with a call to its respective stop function.

function uv_handle_t.is_closing() -> (closing nil | boolean, err nil | string, err_name uv.error_name | nil)

Returns true if the handle is closing or closed, false otherwise. Note: This function should only be used between the initialization of the handle and the arrival of the close callback.

function uv_handle_t.close(callback: fun() -> nil | nil)

Request handle to be closed. callback will be called asynchronously after this call. This MUST be called on each handle before memory is released.

Handles that wrap file descriptors are closed immediately but callback will still be deferred to the next iteration of the event loop. It gives you a chance to free up any resources associated with the handle.

In-progress requests, like uv_connect_t or uv_write_t, are cancelled and have their callbacks called asynchronously with ECANCELED.

function uv_handle_t.ref()

Reference the given handle. References are idempotent, that is, if a handle is already referenced calling this function again will have no effect.

function uv_handle_t.unref()

Un-reference the given handle. References are idempotent, that is, if a handle is not referenced calling this function again will have no effect.

function uv_handle_t.has_ref() -> (has_ref nil | boolean, err nil | string, err_name uv.error_name | nil)

Returns true if the handle referenced, false if not.

function uv_handle_t.send_buffer_size(size: nil | integer) -> (success nil | integer, err nil | string, err_name uv.error_name | nil)

Gets or sets the size of the send buffer that the operating system uses for the socket.

If size is omitted (or 0), this will return the current send buffer size; otherwise, this will use size to set the new send buffer size.

This function works for TCP, pipe and UDP handles on Unix and for TCP and UDP handles on Windows. Note: Linux will set double the size and return double the size of the original set value.

function uv_handle_t.recv_buffer_size(size: nil | integer) -> (success nil | integer, err nil | string, err_name uv.error_name | nil)

Gets or sets the size of the receive buffer that the operating system uses for the socket.

If size is omitted (or 0), this will return the current send buffer size; otherwise, this will use size to set the new send buffer size.

This function works for TCP, pipe and UDP handles on Unix and for TCP and UDP handles on Windows. Note: Linux will set double the size and return double the size of the original set value.

function uv_handle_t.fileno() -> (fileno nil | integer, err nil | string, err_name uv.error_name | nil)

Gets the platform dependent file descriptor equivalent.

The following handles are supported: TCP, pipes, TTY, UDP and poll. Passing any other handle type will fail with EINVAL.

If a handle doesn't have an attached file descriptor yet or the handle itself has been closed, this function will return EBADF. Warning: Be very careful when using this function. libuv assumes it's in control of the file descriptor so any change to it may lead to malfunction.

function uv_handle_t.get_type() -> (type string, enum integer)

Returns the name of the struct for a given handle (e.g. "pipe" for uv_pipe_t) and the libuv enum integer for the handle's type (uv_handle_type).