Nvim :help pages, generated
from source
using the tree-sitter-vimdoc parser.
vim.uv.version()).
require("luv") with vim.uv and omit
uv.run() in Nvim.
uv module, but can
be used in other Lua environments.
local uv = require("luv") -- "luv" when stand-alone, "uv" in luvi apps
local server = uv.new_tcp()
assert(server:bind("127.0.0.1", 1337))
server:listen(128, function (err)
assert(not err, err)
local client = uv.new_tcp()
server:accept(client)
client:read_start(function (err, chunk)
assert(not err, err)
if chunk then
client:write(chunk)
else
client:shutdown()
client:close()
end
end)
end)
print("TCP server listening at 127.0.0.1 port 1337")
uv.run() -- an explicit run call is necessary outside of luvit
uv for
simplicity. This module consists mostly of functions with names corresponding
to their original libuv versions. For example, the libuv function
uv_tcp_bind has a luv version at uv.tcp_bind. Currently, only two
non-function fields exists: uv.constants and uv.errno, which are tables.
uv.tcp_bind(server, host, port) can alternatively be
called as server:bind(host, port). Note that the first argument server
becomes the object and tcp_ is removed from the function name. Method forms
are documented below where they exist.
callable: a function; or a table or userdata with a __call
metamethod
buffer: a string or a sequential table of strings
threadargs: variable arguments (...) of type nil, boolean, number,
string, or userdata, numbers of argument limited to 9.
-- signal start with string input
uv.signal_start("sigterm", function(signame)
print(signame) -- string output: "sigterm"
end)
uv.constants where its keys are uppercase constant names and their
associated values are numbers defined internally by libuv. The values from
this table may be supported as function arguments, but their use may not
change the output type. For example:-- signal start with integer input
uv.signal_start(uv.constants.SIGTERM, function(signame)
print(signame) -- string output: "sigterm"
end)
uv.constants that have associated
lowercase option strings are listed below.
uv.errno table, they are not returned by
luv functions and the libuv functions used to handle them are not exposed.
Instead, if an internal error is encountered, the failing luv function will
return to the caller an assertable nil, err, name tuple:
nil idiomatically indicates failure
err is a string with the format {name}: {message}
{name} is the error name provided internally by uv_err_name
{message} is a human-readable message provided internally by
uv_strerror
name is the same string used to construct err
fail pseudo-type.
0 to indicate
success, or sometimes nothing at all. These cases are documented below.
E2BIG: argument list too long.
EACCES: permission denied.
EADDRINUSE: address already in use.
EADDRNOTAVAIL: address not available.
EAFNOSUPPORT: address family not supported.
EAGAIN: resource temporarily unavailable.
EAI_ADDRFAMILY: address family not supported.
EAI_AGAIN: temporary failure.
EAI_BADFLAGS: bad ai_flags value.
EAI_BADHINTS: invalid value for hints.
EAI_CANCELED: request canceled.
EAI_FAIL: permanent failure.
EAI_FAMILY: ai_family not supported.
EAI_MEMORY: out of memory.
EAI_NODATA: no address.
EAI_NONAME: unknown node or service.
EAI_OVERFLOW: argument buffer overflow.
EAI_PROTOCOL: resolved protocol is unknown.
EAI_SERVICE: service not available for socket type.
EAI_SOCKTYPE: socket type not supported.
EALREADY: connection already in progress.
EBADF: bad file descriptor.
EBUSY: resource busy or locked.
ECANCELED: operation canceled.
ECHARSET: invalid Unicode character.
ECONNABORTED: software caused connection abort.
ECONNREFUSED: connection refused.
ECONNRESET: connection reset by peer.
EDESTADDRREQ: destination address required.
EEXIST: file already exists.
EFAULT: bad address in system call argument.
EFBIG: file too large.
EHOSTUNREACH: host is unreachable.
EINTR: interrupted system call.
EINVAL: invalid argument.
EIO: i/o error.
EISCONN: socket is already connected.
EISDIR: illegal operation on a directory.
ELOOP: too many symbolic links encountered.
EMFILE: too many open files.
EMSGSIZE: message too long.
ENAMETOOLONG: name too long.
ENETDOWN: network is down.
ENETUNREACH: network is unreachable.
ENFILE: file table overflow.
ENOBUFS: no buffer space available.
ENODEV: no such device.
ENOENT: no such file or directory.
ENOMEM: not enough memory.
ENONET: machine is not on the network.
ENOPROTOOPT: protocol not available.
ENOSPC: no space left on device.
ENOSYS: function not implemented.
ENOTCONN: socket is not connected.
ENOTDIR: not a directory.
ENOTEMPTY: directory not empty.
ENOTSOCK: socket operation on non-socket.
ENOTSUP: operation not supported on socket.
EOVERFLOW: value too large for defined data type.
EPERM: operation not permitted.
EPIPE: broken pipe.
EPROTO: protocol error.
EPROTONOSUPPORT: protocol not supported.
EPROTOTYPE: protocol wrong type for socket.
ERANGE: result too large.
EROFS: read-only file system.
ESHUTDOWN: cannot send after transport endpoint shutdown.
ESPIPE: invalid seek.
ESRCH: no such process.
ETIMEDOUT: connection timed out.
ETXTBSY: text file is busy.
EXDEV: cross-device link not permitted.
UNKNOWN: unknown error.
EOF: end of file.
ENXIO: no such device or address.
EMLINK: too many links.
ENOTTY: inappropriate ioctl for device.
EFTYPE: inappropriate file type or format.
EILSEQ: illegal byte sequence.
ESOCKTNOSUPPORT: socket type not supported.
integer)
string)
uv_loop_t - Event loopuv.run("nowait") to poll in one
thread and run the event loop's callbacks in another Note: Embedding a
kqueue fd in another kqueue pollset doesn't work on all platforms. It's
not an error to add the fd but it never generates events.
integer?)
integer)
true if there are referenced active handles, active requests, or
closing handles in the loop; otherwise, false.
boolean?) alive
(string?) err
(uv.error_name?) err_name
loop_close(). Call this function only after
the loop has finished executing and all open handles and requests have
been closed, or it will return EBUSY.
0?) success
(string?) err
(uv.error_name?) err_name
"block_signal": Block a signal when polling for new events. The second
argument to loop_configure() is the signal name (as a lowercase string)
or the signal number. This operation is currently only implemented for
"sigprof" signals, to suppress unnecessary wakeups when using a
sampling profiler. Requesting other signals will fail with EINVAL.
"metrics_idle_time": Accumulate the amount of idle time the event loop
spends in the event provider. This option is necessary to use
metrics_idle_time().
uv.loop_configure("block_signal", "sigprof")
ENOSYS error; it means the loop option
is not supported by the platform.
{option} (string)
{...} (any) depends on option
0?) success
(string?) err
(uv.error_name?) err_name
nil is returned instead.
string?)
uv.update_time() for details and
rationale.
uv.hrtime() if you need sub-millisecond
granularity.
integer)
{mode})uv.run()"default": Runs the event loop until there are no more active and
referenced handles or requests. Returns true if uv.stop() was called
and there are still active handles or requests. Returns false in all
other cases.
"once": Poll for I/O once. Note that this function blocks if there are
no pending callbacks. Returns false when done (no active handles or
requests left), or true if more callbacks are expected (meaning you
should run the event loop again sometime in the future).
"nowait": Poll for I/O once but don't block if there are no pending
callbacks. Returns false if done (no active handles or requests left),
or true if more callbacks are expected (meaning you should run the
event loop again sometime in the future). Note: Luvit will implicitly
call uv.run() after loading user code, but if you use the luv bindings
directly, you need to call this after registering your initial set of
event callbacks to start the event loop.
{mode} (string?)
boolean?) running
(string?) err
(uv.error_name?) err_name
uv.run() to end as soon as possible. This
will happen not sooner than the next loop iteration. If this function was
called before blocking for I/O, the loop won't block for I/O on this
iteration.
{callback})uv.walk()callback will be executed with each handle.
Example-- Example usage of uv.walk to close all handles that aren't already closing.
uv.walk(function (handle)
if not handle:is_closing() then
handle:close()
end
end)
{callback} (fun(handle: uv.uv_handle_t))
uv_req_t - Base requestuserdata
uv_req_t is the base type for all libuv request types.
{req})uv.cancel()uv_fs_t, uv_getaddrinfo_t,
uv_getnameinfo_t and uv_work_t requests is currently supported.
{req} (uv.uv_req_t)
0?) success
(string?) err
(uv.error_name?) err_name
{req})uv.req_get_type()"fs" for
uv_fs_t) and the libuv enum integer for the request's type
(uv_req_type).
{req} (uv.uv_req_t)
string) type
(integer) enum
{req})uv.write_nwritten()uv_write_t request. Only valid
when called from within the write callback (uv_write_cb).
uv.cancel() and the callback receives an ECANCELED error, to determine
how many bytes were actually written before the cancellation took effect.
req is not a write request (uv_write_t).
{req} (uv.uv_write_t)
integer) nwritten
uv_fs_t, uv_getaddrinfo_t,
uv_getnameinfo_t and uv_work_t requests is currently supported.
0?) success
(string?) err
(uv.error_name?) err_name
"fs" for
uv_fs_t) and the libuv enum integer for the request's type
(uv_req_type).
string) type
(integer) enum
uv_write_t request. Only valid
when called from within the write callback (uv_write_cb).
uv.cancel() and the callback receives an ECANCELED error, to determine
how many bytes were actually written before the cancellation took effect.
req is not a write request (uv_write_t).
integer) nwritten
uv_handle_t - Base handleuserdata
uv_handle_t is the base type for all libuv handle types. All API
functions defined here work with any handle type.
{is_active} (fun(self: uv.uv_handle_t): boolean?, string?, uv.error_name?)
See uv_handle_t:is_active().
{is_closing} (fun(self: uv.uv_handle_t): boolean?, string?, uv.error_name?)
See uv_handle_t:is_closing().
{recv_buffer_size} (fun(self: uv.uv_handle_t, size: integer?): integer?, string?, uv.error_name?)
See uv_handle_t:recv_buffer_size().
{send_buffer_size} (fun(self: uv.uv_handle_t, size: integer?): integer?, string?, uv.error_name?)
See uv_handle_t:send_buffer_size().
callback will be called asynchronously
after this call. This MUST be called on each handle before memory is
released.
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.
uv_connect_t or uv_write_t, are cancelled
and have their callbacks called asynchronously with ECANCELED.
{handle} (uv.uv_handle_t)
{callback} (fun()?)
{handle})uv.fileno()EINVAL.
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.
{handle} (uv.uv_handle_t)
integer?) fileno
(string?) err
(uv.error_name?) err_name
{handle})uv.handle_get_type()"pipe" for
uv_pipe_t) and the libuv enum integer for the handle's type
(uv_handle_type).
{handle} (uv.uv_handle_t)
string) type
(integer) enum
{handle} (uv.uv_handle_t)
boolean?) has_ref
(string?) err
(uv.error_name?) err_name
{handle})uv.is_active()true if the handle is active, false if it's inactive. What
"active” means depends on the type of handle:
uv.close().
uv.check_start(), uv.idle_start(),
uv.timer_start() etc. until it has been stopped with a call to its
respective stop function.
{handle} (uv.uv_handle_t)
boolean?) active
(string?) err
(uv.error_name?) err_name
{handle})uv.is_closing()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.
{handle} (uv.uv_handle_t)
boolean?) closing
(string?) err
(uv.error_name?) err_name
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.
{handle} (uv.uv_handle_t)
{size} (integer?)
integer?) success
(string?) err
(uv.error_name?) err_name
{handle})uv.ref(){handle} (uv.uv_handle_t)
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.
{handle} (uv.uv_handle_t)
{size} (integer?)
integer?) success
(string?) err
(uv.error_name?) err_name
{handle})uv.unref(){handle} (uv.uv_handle_t)
{callback})uv_handle_t:close()callback will be called asynchronously
after this call. This MUST be called on each handle before memory is
released.
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.
uv_connect_t or uv_write_t, are cancelled
and have their callbacks called asynchronously with ECANCELED.
{callback} (fun()?)
EINVAL.
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.
integer?) fileno
(string?) err
(uv.error_name?) err_name
"pipe" for
uv_pipe_t) and the libuv enum integer for the handle's type
(uv_handle_type).
string) type
(integer) enum
boolean?) has_ref
(string?) err
(uv.error_name?) err_name
true if the handle is active, false if it's inactive. What
"active” means depends on the type of handle:
uv.close().
uv.check_start(), uv.idle_start(),
uv.timer_start() etc. until it has been stopped with a call to its
respective stop function.
boolean?) active
(string?) err
(uv.error_name?) err_name
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.
boolean?) closing
(string?) err
(uv.error_name?) err_name
{size})uv_handle_t:recv_buffer_size()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.
{size} (integer?)
integer?) success
(string?) err
(uv.error_name?) err_name
{size})uv_handle_t:send_buffer_size()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.
{size} (integer?)
integer?) success
(string?) err
(uv.error_name?) err_name
uv.unref()
after calling uv.timer_start().
uv.is_active() for a
more detailed explanation on what being active involves.
uv_timer_t - Timer handle{start} (fun(self: uv.uv_timer_t, timeout: integer, repeat_: integer, callback: fun()): 0?, string?, uv.error_name?)
See uv_timer_t:start().
uv_timer_t. Returns the Lua userdata
wrapping it. Example-- Creating a simple setTimeout wrapper
local function setTimeout(timeout, callback)
local timer = uv.new_timer()
timer:start(timeout, 0, function ()
timer:stop()
timer:close()
callback()
end)
return timer
end
-- Creating a simple setInterval wrapper
local function setInterval(interval, callback)
local timer = uv.new_timer()
timer:start(interval, interval, function ()
callback()
end)
return timer
end
-- And clearInterval
local function clearInterval(timer)
timer:stop()
timer:close()
end
uv.uv_timer_t?) timer
(string?) err
(uv.error_name?) err_name
{timer})uv.timer_again()EINVAL.
{timer} (uv.uv_timer_t)
0?) success
(string?) err
(uv.error_name?) err_name
{timer})uv.timer_get_due_in()uv.now().
{timer} (uv.uv_timer_t)
integer) due_in
{timer})uv.timer_get_repeat(){timer} (uv.uv_timer_t)
integer) repeat_
{timer} (uv.uv_timer_t)
{repeat_} (integer)
timeout and repeat are in milliseconds.
timeout is zero, the callback fires on the next event loop iteration.
If repeat is non-zero, the callback fires first after timeout
milliseconds and then repeatedly after repeat milliseconds.
{timer} (uv.uv_timer_t)
{timeout} (integer)
{repeat_} (integer)
{callback} (fun())
0?) success
(string?) err
(uv.error_name?) err_name
{timer})uv.timer_stop(){timer} (uv.uv_timer_t)
0?) success
(string?) err
(uv.error_name?) err_name
EINVAL.
0?) success
(string?) err
(uv.error_name?) err_name
uv.now().
integer) due_in
integer) repeat_
{repeat_})uv_timer_t:set_repeat(){repeat_} (integer)
timeout and repeat are in milliseconds.
timeout is zero, the callback fires on the next event loop iteration.
If repeat is non-zero, the callback fires first after timeout
milliseconds and then repeatedly after repeat milliseconds.
{timeout} (integer)
{repeat_} (integer)
{callback} (fun())
0?) success
(string?) err
(uv.error_name?) err_name
0?) success
(string?) err
(uv.error_name?) err_name
uv_prepare_t - Prepare handlelocal prepare = uv.new_prepare()
prepare:start(function()
print("Before I/O polling")
end)
{start} (fun(self: uv.uv_prepare_t, callback: fun()): 0?, string?, uv.error_name?)
See uv_prepare_t:start().
uv_prepare_t. Returns the Lua userdata
wrapping it.
uv.uv_prepare_t)
{prepare} (uv.uv_prepare_t)
{callback} (fun())
0?) success
(string?) err
(uv.error_name?) err_name
{prepare})uv.prepare_stop(){prepare} (uv.uv_prepare_t)
0?) success
(string?) err
(uv.error_name?) err_name
{callback})uv_prepare_t:start(){callback} (fun())
0?) success
(string?) err
(uv.error_name?) err_name
0?) success
(string?) err
(uv.error_name?) err_name
uv_check_t - Check handlelocal check = uv.new_check()
check:start(function()
print("After I/O polling")
end)
{start} (fun(self: uv.uv_check_t, callback: fun()): 0?, string?, uv.error_name?)
See uv_check_t:start().
{check} (uv.uv_check_t)
{callback} (fun())
0?) success
(string?) err
(uv.error_name?) err_name
{check})uv.check_stop(){check} (uv.uv_check_t)
0?) success
(string?) err
(uv.error_name?) err_name
uv_check_t. Returns the Lua userdata
wrapping it.
uv.uv_check_t)
{callback})uv_check_t:start(){callback} (fun())
0?) success
(string?) err
(uv.error_name?) err_name
0?) success
(string?) err
(uv.error_name?) err_name
uv_idle_t - Idle handlelocal idle = uv.new_idle()
idle:start(function()
print("Before I/O polling, no blocking")
end)
{start} (fun(self: uv.uv_idle_t, callback: fun()): 0?, string?, uv.error_name?)
See uv_idle_t:start().
{idle} (uv.uv_idle_t)
{callback} (fun())
0?) success
(string?) err
(uv.error_name?) err_name
{idle})uv.idle_stop(){idle} (uv.uv_idle_t)
0?) success
(string?) err
(uv.error_name?) err_name
uv_idle_t. Returns the Lua userdata
wrapping it.
uv.uv_idle_t)
{callback})uv_idle_t:start(){callback} (fun())
0?) success
(string?) err
(uv.error_name?) err_name
0?) success
(string?) err
(uv.error_name?) err_name
uv_async_t - Async handlelocal async
async = uv.new_async(function()
print("async operation ran")
async:close()
end)
async:send()
{send} (fun(self: uv.uv_async_t, ...: uv.threadargs): 0?, string?, uv.error_name?)
See uv_async_t:send().
uv.async_send(async), that is, not every call to it will yield an
execution of the callback. For example: if uv.async_send() is called 5
times in a row before the callback is called, the callback will only be
called once. If uv.async_send() is called again after the callback was
called, it will be called again.
{async} (uv.uv_async_t)
{...} (uv.threadargs)
0?) success
(string?) err
(uv.error_name?) err_name
{callback})uv.new_async()uv_async_t. Returns the Lua userdata
wrapping it. Note: Unlike other handle initialization functions, this
immediately starts the handle.
{callback} (fun(...: uv.threadargs))
uv.uv_async_t?) async
(string?) err
(uv.error_name?) err_name
{...})uv_async_t:send()uv.async_send(async), that is, not every call to it will yield an
execution of the callback. For example: if uv.async_send() is called 5
times in a row before the callback is called, the callback will only be
called once. If uv.async_send() is called again after the callback was
called, it will be called again.
{...} (uv.threadargs)
0?) success
(string?) err
(uv.error_name?) err_name
uv_poll_t - Poll handleuv_poll_t for any other purpose is not
recommended; uv_tcp_t, uv_udp_t, etc. provide an implementation that
is faster and more scalable than what can be achieved with uv_poll_t,
especially on Windows.
uv.poll_stop() or uv.close().
{start} (fun(self: uv.uv_poll_t, events: string?, callback: fun(err: string?, events: string?)): 0?, string?, uv.error_name?)
See uv_poll_t:start().
{fd})uv.new_poll(){fd} (integer)
uv.uv_poll_t?) poll
(string?) err
(uv.error_name?) err_name
{fd})uv.new_socket_poll()uv.new_poll(). On windows it takes a SOCKET handle.
{fd} (integer)
uv.uv_poll_t?) poll
(string?) err
(uv.error_name?) err_name
events are: "r", "w", "rw",
"d", "rd", "wd", "rwd", "p", "rp", "wp", "rwp", "dp",
"rdp", "wdp", or "rwdp" where r is READABLE, w is WRITABLE,
d is DISCONNECT, and p is PRIORITIZED. As soon as an event is
detected the callback will be called with status set to 0, and the
detected events set on the events field.
uv.poll_start() on a
handle that is already active is fine. Doing so will update the events
mask that is being watched for.
{poll} (uv.uv_poll_t)
{events} (string?)
{callback} (fun(err: string?, events: string?))
0?) success
(string?) err
(uv.error_name?) err_name
{poll})uv.poll_stop(){poll} (uv.uv_poll_t)
0?) success
(string?) err
(uv.error_name?) err_name
events are: "r", "w", "rw",
"d", "rd", "wd", "rwd", "p", "rp", "wp", "rwp", "dp",
"rdp", "wdp", or "rwdp" where r is READABLE, w is WRITABLE,
d is DISCONNECT, and p is PRIORITIZED. As soon as an event is
detected the callback will be called with status set to 0, and the
detected events set on the events field.
uv.poll_start() on a
handle that is already active is fine. Doing so will update the events
mask that is being watched for.
{events} (string?)
{callback} (fun(err: string?, events: string?))
0?) success
(string?) err
(uv.error_name?) err_name
0?) success
(string?) err
(uv.error_name?) err_name
uv_signal_t - Signal handle-- Create a new signal handler
local signal = uv.new_signal()
-- Define a handler function
uv.signal_start(signal, "sigint", function(signame)
print("got " .. signame .. ", shutting down")
os.exit(1)
end)
{start} (fun(self: uv.uv_signal_t, signame: string|integer, callback: fun(signame: string)): 0?, string?, uv.error_name?)
See uv_signal_t:start().
{start_oneshot} (fun(self: uv.uv_signal_t, signame: string|integer, callback: fun(signame: string)): 0?, string?, uv.error_name?)
See uv_signal_t:start_oneshot().
uv_signal_t. Returns the Lua userdata
wrapping it.
uv.uv_signal_t?) signal
(string?) err
(uv.error_name?) err_name
signame input and output values.
String signame values are case-insensitive.
{signal} (uv.uv_signal_t)
{signame} (string|integer)
{callback} (fun(signame: string))
0?) success
(string?) err
(uv.error_name?) err_name
uv.signal_start() but the signal handler is reset
the moment the signal is received.
signame input and output values.
String signame values are case-insensitive.
{signal} (uv.uv_signal_t)
{signame} (string|integer)
{callback} (fun(signame: string))
0?) success
(string?) err
(uv.error_name?) err_name
{signal})uv.signal_stop(){signal} (uv.uv_signal_t)
0?) success
(string?) err
(uv.error_name?) err_name
signame input and output values.
String signame values are case-insensitive.
{signame} (string|integer)
{callback} (fun(signame: string))
0?) success
(string?) err
(uv.error_name?) err_name
uv.signal_start() but the signal handler is reset
the moment the signal is received.
signame input and output values.
String signame values are case-insensitive.
{signame} (string|integer)
{callback} (fun(signame: string))
0?) success
(string?) err
(uv.error_name?) err_name
0?) success
(string?) err
(uv.error_name?) err_name
uv_process_t - Process handle{args} (string[]?) Command line arguments as a list of
strings. The first string should not be the path to
the program, since that is already provided via
path. On Windows, this uses CreateProcess which
concatenates the arguments into a string. This can
cause some strange errors (see options.verbatim
below for Windows).
{cwd} (string?) Set the current working directory for the
sub-process.
{detached} (boolean?) If true, spawn the child process in a
detached state - this will make it a process group
leader, and will effectively enable the child to keep
running after the parent exits. Note that the child
process will still keep the parent's event loop alive
unless the parent process calls uv.unref() on the
child's process handle.
{env} (string[]?) Set environment variables for the new
process. Each entry should be a string in the form of
NAME=VALUE.
{gid} (integer?) Set the child process' group id.
{hide} (boolean?) If true, hide the subprocess console
window that would normally be created. This option is
only meaningful on Windows systems. On Unix it is
silently ignored.
{hide_console} (boolean?) Hide the subprocess console window on
Windows.
{hide_gui} (boolean?) Hide the subprocess GUI window on
Windows.
{stdio} (table<integer, integer|uv.uv_stream_t?>?) Set the
file descriptors that will be made available to the
child process. The convention is that the first
entries are stdin, stdout, and stderr.
integer, then the child process inherits that
same zero-indexed fd from the parent process.
uv_stream_t handles are passed in, those are
used as a read-write pipe or inherited stream
depending if the stream has a valid fd.
nil, means to ignore that fd in the child
process.
{uid} (integer?) Set the child process' user id.
{verbatim} (boolean?) If true, do not wrap any arguments in
quotes, or perform any other escaping, when converting
the argument list into a command line string. This
option is only meaningful on Windows systems. On Unix
it is silently ignored.
{kill} (fun(self: uv.uv_process_t, signame: string|integer?): 0?, string?, uv.error_name?)
See uv_process_t:kill().
uv_signal_t for signal support, specially on Windows.
signame input values.
{pid} (integer)
{signame} (string|integer?)
0?) success
(string?) err
(uv.error_name?) err_name
{process})uv.process_get_pid(){process} (uv.uv_process_t)
integer)
uv_signal_t for signal support, specially on Windows.
signame input values.
{process} (uv.uv_process_t)
{signame} (string|integer?)
0?) success
(string?) err
(uv.error_name?) err_name
local stdin = uv.new_pipe()
local stdout = uv.new_pipe()
local stderr = uv.new_pipe()
print("stdin", stdin)
print("stdout", stdout)
print("stderr", stderr)
local handle, pid = uv.spawn("cat", {
stdio = {stdin, stdout, stderr}
}, function(code, signal) -- on exit
print("exit code", code)
print("exit signal", signal)
end)
print("process opened", handle, pid)
uv.read_start(stdout, function(err, data)
assert(not err, err)
if data then
print("stdout chunk", stdout, data)
else
print("stdout end", stdout)
end
end)
uv.read_start(stderr, function(err, data)
assert(not err, err)
if data then
print("stderr chunk", stderr, data)
else
print("stderr end", stderr)
end
end)
uv.write(stdin, "Hello World")
uv.shutdown(stdin, function()
print("stdin shutdown", stdin)
uv.close(handle, function()
print("process closed", handle, pid)
end)
end)
on_exit is called with an exit code and
signal.
{path} (string)
{options} (uv.spawn.options)
{on_exit} (fun(code: integer, signal: integer)?)
uv.uv_process_t?) handle
(integer|string) pid_or_err
(uv.error_name?) err_name
integer)
{signame})uv_process_t:kill()uv_signal_t for signal support, specially on Windows.
signame input values.
{signame} (string|integer?)
0?) success
(string?) err
(uv.error_name?) err_name
uv_stream_t - Stream handle{accept} (fun(self: uv.uv_stream_t, client_stream: uv.uv_stream_t): 0?, string?, uv.error_name?)
See uv_stream_t:accept().
{listen} (fun(self: uv.uv_stream_t, backlog: integer, callback: fun(err: string?)): 0?, string?, uv.error_name?)
See uv_stream_t:listen().
{read_start} (fun(self: uv.uv_stream_t, callback: fun(err: string?, data: string?)): 0?, string?, uv.error_name?)
See uv_stream_t:read_start().
{set_blocking} (fun(self: uv.uv_stream_t, blocking: boolean): 0?, string?, uv.error_name?)
See uv_stream_t:set_blocking().
{shutdown} (fun(self: uv.uv_stream_t, callback: fun(err: string?)?): uv.uv_shutdown_t?, string?, uv.error_name?)
See uv_stream_t:shutdown().
{try_write} (fun(self: uv.uv_stream_t, data: uv.buffer): integer?, string?, uv.error_name?)
See uv_stream_t:try_write().
{try_write2} (fun(self: uv.uv_stream_t, data: uv.buffer, send_handle: uv.uv_stream_t): integer?, string?, uv.error_name?)
See uv_stream_t:try_write2().
{write} (fun(self: uv.uv_stream_t, data: uv.buffer, callback: fun(err: string?)?): uv.uv_write_t?, string?, uv.error_name?)
See uv_stream_t:write().
{write2} (fun(self: uv.uv_stream_t, data: uv.buffer, send_handle: uv.uv_stream_t, callback: fun(err: string?)?): uv.uv_write_t?, string?, uv.error_name?)
See uv_stream_t:write2().
uv.listen() to accept incoming
connections. Call this function after receiving a callback to accept the
connection.
server:listen(128, function (err)
local client = uv.new_tcp()
server:accept(client)
end)
{stream} (uv.uv_stream_t)
{client_stream} (uv.uv_stream_t)
0?) success
(string?) err
(uv.error_name?) err_name
{stream} (uv.uv_stream_t)
boolean)
{stream} (uv.uv_stream_t)
boolean)
backlog indicates the number
of connections the kernel might queue, same as listen(2). When a new
incoming connection is received the callback is called.
{stream} (uv.uv_stream_t)
{backlog} (integer)
{callback} (fun(err: string?))
0?) success
(string?) err
(uv.error_name?) err_name
uv.read_stop() is called. When
we've reached EOF, data will be nil. Examplestream:read_start(function (err, chunk)
if err then
-- handle read error
elseif chunk then
-- handle data
else
-- handle disconnect
end
end)
{stream} (uv.uv_stream_t)
{callback} (fun(err: string?, data: string?))
0?) success
(string?) err
(uv.error_name?) err_name
{stream})uv.read_stop(){stream} (uv.uv_stream_t)
0?) success
(string?) err
(uv.error_name?) err_name
{stream} (uv.uv_stream_t)
{callback} (fun(err: string?)?)
uv.uv_shutdown_t?) shutdown
(string?) err
(uv.error_name?) err_name
{stream})uv.stream_get_write_queue_size(){stream} (uv.uv_stream_t)
integer)
uv_pipe_t handles. Also libuv currently
makes no ordering guarantee when the blocking mode is changed after write
requests have already been submitted. Therefore it is recommended to set
the blocking mode immediately after opening or creating the stream.
{stream} (uv.uv_stream_t)
{blocking} (boolean)
0?) success
(string?) err
(uv.error_name?) err_name
uv.write(), but won't queue a write request if it can't be
completed immediately.
{stream} (uv.uv_stream_t)
{data} (uv.buffer)
integer?) bytes_written
(string?) err
(uv.error_name?) err_name
uv.write2(), but with the properties of uv.try_write(). Not
supported on Windows, where it returns UV_EAGAIN.
{stream} (uv.uv_stream_t)
{data} (uv.buffer)
{send_handle} (uv.uv_stream_t)
integer?) bytes_written
(string?) err
(uv.error_name?) err_name
data can either be a Lua string or a table of strings. If a table is
passed in, the C backend will use writev to send all strings in a single
system call.
callback is for knowing when the write is complete.
{stream} (uv.uv_stream_t)
{data} (uv.buffer)
{callback} (fun(err: string?)?)
uv.uv_write_t?) write
(string?) err
(uv.error_name?) err_name
ipc option true. Note: send_handle must be a TCP
socket or pipe, which is a server or a connection (listening or connected
state). Bound sockets or pipes will be assumed to be servers.
{stream} (uv.uv_stream_t)
{data} (uv.buffer)
{send_handle} (uv.uv_stream_t)
{callback} (fun(err: string?)?)
uv.uv_write_t?) write
(string?) err
(uv.error_name?) err_name
{client_stream})uv_stream_t:accept()uv.listen() to accept incoming
connections. Call this function after receiving a callback to accept the
connection.
server:listen(128, function (err)
local client = uv.new_tcp()
server:accept(client)
end)
{client_stream} (uv.uv_stream_t)
0?) success
(string?) err
(uv.error_name?) err_name
integer)
true if the stream is readable, false otherwise.
boolean)
true if the stream is writable, false otherwise.
boolean)
backlog indicates the number
of connections the kernel might queue, same as listen(2). When a new
incoming connection is received the callback is called.
{backlog} (integer)
{callback} (fun(err: string?))
0?) success
(string?) err
(uv.error_name?) err_name
{callback})uv_stream_t:read_start()uv.read_stop() is called. When
we've reached EOF, data will be nil. Examplestream:read_start(function (err, chunk)
if err then
-- handle read error
elseif chunk then
-- handle data
else
-- handle disconnect
end
end)
{callback} (fun(err: string?, data: string?))
0?) success
(string?) err
(uv.error_name?) err_name
0?) success
(string?) err
(uv.error_name?) err_name
{blocking})uv_stream_t:set_blocking()uv_pipe_t handles. Also libuv currently
makes no ordering guarantee when the blocking mode is changed after write
requests have already been submitted. Therefore it is recommended to set
the blocking mode immediately after opening or creating the stream.
{blocking} (boolean)
0?) success
(string?) err
(uv.error_name?) err_name
{callback})uv_stream_t:shutdown(){callback} (fun(err: string?)?)
uv.uv_shutdown_t?) shutdown
(string?) err
(uv.error_name?) err_name
{data})uv_stream_t:try_write()uv.write(), but won't queue a write request if it can't be
completed immediately.
{data} (uv.buffer)
integer?) bytes_written
(string?) err
(uv.error_name?) err_name
uv.write2(), but with the properties of uv.try_write(). Not
supported on Windows, where it returns UV_EAGAIN.
{data} (uv.buffer)
{send_handle} (uv.uv_stream_t)
integer?) bytes_written
(string?) err
(uv.error_name?) err_name
data can either be a Lua string or a table of strings. If a table is
passed in, the C backend will use writev to send all strings in a single
system call.
callback is for knowing when the write is complete.
{data} (uv.buffer)
{callback} (fun(err: string?)?)
uv.uv_write_t?) write
(string?) err
(uv.error_name?) err_name
ipc option true. Note: send_handle must be a TCP
socket or pipe, which is a server or a connection (listening or connected
state). Bound sockets or pipes will be assumed to be servers.
{data} (uv.buffer)
{send_handle} (uv.uv_stream_t)
{callback} (fun(err: string?)?)
uv.uv_write_t?) write
(string?) err
(uv.error_name?) err_name
uv_tcp_t - TCP handle{bind} (fun(self: uv.uv_tcp_t, host: string, port: integer, flags: { ipv6only: boolean? }?): 0?, string?, uv.error_name?)
See uv_tcp_t:bind().
{close_reset} (fun(self: uv.uv_tcp_t, callback: fun()?): 0?, string?, uv.error_name?)
See uv_tcp_t:close_reset().
{connect} (fun(self: uv.uv_tcp_t, host: string, port: integer, callback: fun(err: string?)?): uv.uv_connect_t?, string?, uv.error_name?)
See uv_tcp_t:connect().
{getpeername} (fun(self: uv.uv_tcp_t): uv.socketinfo?, string?, uv.error_name?)
See uv_tcp_t:getpeername().
{getsockname} (fun(self: uv.uv_tcp_t): uv.socketinfo?, string?, uv.error_name?)
See uv_tcp_t:getsockname().
{keepalive} (fun(self: uv.uv_tcp_t, enable: boolean, delay: integer?, intvl: integer?, cnt: integer?): 0?, string?, uv.error_name?)
See uv_tcp_t:keepalive().
{nodelay} (fun(self: uv.uv_tcp_t, enable: boolean): 0?, string?, uv.error_name?)
See uv_tcp_t:nodelay().
{simultaneous_accepts} (fun(self: uv.uv_tcp_t, enable: boolean): 0?, string?, uv.error_name?)
See uv_tcp_t:simultaneous_accepts().
{flags})uv.new_tcp()uv_tcp_t. Returns the Lua userdata
wrapping it.
flags must be a valid address family. See luv-constants for
supported address family input values.
{flags} (string|integer?)
uv.uv_tcp_t?) tcp
(string?) err
(uv.error_name?) err_name
uv.tcp_open, used with uv.spawn, or
for any other purpose.
socktype input values.
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).
nonblock: Opens the specified socket handle for OVERLAPPED or
FIONBIO/`O_NONBLOCK` I/O usage. This is recommended for handles that
will be used by libuv, and not usually recommended otherwise.
socketpair(2) with a domain of AF_UNIX. Example-- Simple read/write with tcp
local fds = uv.socketpair(nil, nil, {nonblock=true}, {nonblock=true})
local sock1 = uv.new_tcp()
sock1:open(fds[1])
local sock2 = uv.new_tcp()
sock2:open(fds[2])
sock1:write("hello")
sock2:read_start(function(err, chunk)
assert(not err, err)
print(chunk)
end)
{socktype} (string|integer?)
{protocol} (string|integer?)
{flags1} ({ nonblock: boolean? }?)
{flags2} ({ nonblock: boolean? }?)
[integer, integer]?) fds
(string?) err
(uv.error_name?) err_name
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.
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.
0 to let the OS assign an ephemeral port. You can look it
up later using uv.tcp_getsockname().
{tcp} (uv.uv_tcp_t)
{host} (string)
{port} (integer)
{flags} ({ ipv6only: boolean? }?)
0?) success
(string?) err
(uv.error_name?) err_name
uv.close(). Due to some platform inconsistencies, mixing of
uv.shutdown() and uv.tcp_close_reset() calls is not allowed.
{tcp} (uv.uv_tcp_t)
{callback} (fun()?)
0?) success
(string?) err
(uv.error_name?) err_name
local client = uv.new_tcp()
client:connect("127.0.0.1", 8080, function (err)
-- check error and carry on.
end)
{tcp} (uv.uv_tcp_t)
{host} (string)
{port} (integer)
{callback} (fun(err: string?)?)
uv.uv_connect_t?) connect
(string?) err
(uv.error_name?) err_name
{tcp})uv.tcp_getpeername()family output values.
{tcp} (uv.uv_tcp_t)
uv.socketinfo?) address
(string?) err
(uv.error_name?) err_name
{tcp})uv.tcp_getsockname()family output values.
{tcp} (uv.uv_tcp_t)
uv.socketinfo?) address
(string?) err
(uv.error_name?) err_name
delay is the initial delay in seconds,
intvl is the time in seconds between individual keep-alive probes, and
cnt is the number of probes to send before assuming the connection is
dead. ignored when enable is false. Note: intvl and cnt are only
supported with Libuv >= 1.52.0.
{tcp} (uv.uv_tcp_t)
{enable} (boolean)
{delay} (integer?)
{intvl} (integer?)
{cnt} (integer?)
0?) success
(string?) err
(uv.error_name?) err_name
{tcp} (uv.uv_tcp_t)
{enable} (boolean)
0?) success
(string?) err
(uv.error_name?) err_name
{tcp} (uv.uv_tcp_t)
{sock} (integer)
0?) success
(string?) err
(uv.error_name?) err_name
{tcp} (uv.uv_tcp_t)
{enable} (boolean)
0?) success
(string?) err
(uv.error_name?) err_name
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.
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.
0 to let the OS assign an ephemeral port. You can look it
up later using uv.tcp_getsockname().
{host} (string)
{port} (integer)
{flags} ({ ipv6only: boolean? }?)
0?) success
(string?) err
(uv.error_name?) err_name
{callback})uv_tcp_t:close_reset()uv.close(). Due to some platform inconsistencies, mixing of
uv.shutdown() and uv.tcp_close_reset() calls is not allowed.
{callback} (fun()?)
0?) success
(string?) err
(uv.error_name?) err_name
local client = uv.new_tcp()
client:connect("127.0.0.1", 8080, function (err)
-- check error and carry on.
end)
{host} (string)
{port} (integer)
{callback} (fun(err: string?)?)
uv.uv_connect_t?) connect
(string?) err
(uv.error_name?) err_name
family output values.
uv.socketinfo?) address
(string?) err
(uv.error_name?) err_name
family output values.
uv.socketinfo?) address
(string?) err
(uv.error_name?) err_name
delay is the initial delay in seconds,
intvl is the time in seconds between individual keep-alive probes, and
cnt is the number of probes to send before assuming the connection is
dead. ignored when enable is false. Note: intvl and cnt are only
supported with Libuv >= 1.52.0.
{enable} (boolean)
{delay} (integer?)
{intvl} (integer?)
{cnt} (integer?)
0?) success
(string?) err
(uv.error_name?) err_name
{enable})uv_tcp_t:nodelay(){enable} (boolean)
0?) success
(string?) err
(uv.error_name?) err_name
{sock})uv_tcp_t:open(){sock} (integer)
0?) success
(string?) err
(uv.error_name?) err_name
{enable})uv_tcp_t:simultaneous_accepts(){enable} (boolean)
0?) success
(string?) err
(uv.error_name?) err_name
uv_pipe_t - Pipe handle{read} (integer) (file descriptor)
{write} (integer) (file descriptor)
local pipe = uv.new_pipe(false)
pipe:bind('/tmp/sock.test')
pipe:listen(128, function()
local client = uv.new_pipe(false)
pipe:accept(client)
client:write("hello!\n")
client:close()
end)
{bind2} (fun(self: uv.uv_pipe_t, name: string, flags: integer|table?): 0?, string?, uv.error_name?)
See uv_pipe_t:bind2().
{chmod} (fun(self: uv.uv_pipe_t, flags: string): 0?, string?, uv.error_name?)
See uv_pipe_t:chmod().
{connect} (fun(self: uv.uv_pipe_t, name: string, callback: fun(err: string?)?): uv.uv_connect_t?, string?, uv.error_name?)
See uv_pipe_t:connect().
{connect2} (fun(self: uv.uv_pipe_t, name: string, flags: integer|table?, callback: fun(err: string?)?): uv.uv_connect_t?, string?, uv.error_name?)
See uv_pipe_t:connect2().
{getpeername} (fun(self: uv.uv_pipe_t): string?, string?, uv.error_name?)
See uv_pipe_t:getpeername().
{getsockname} (fun(self: uv.uv_pipe_t): string?, string?, uv.error_name?)
See uv_pipe_t:getsockname().
{ipc})uv.new_pipe()uv_pipe_t. Returns the Lua userdata
wrapping it. The ipc argument is a boolean to indicate if this pipe will
be used for handle passing between processes.
{ipc} (boolean?)
uv.uv_pipe_t?) pipe
(string?) err
(uv.error_name?) err_name
write fd and read from the read fd. The resulting handles can be
passed to pipe_open, used with spawn, or for any other purpose.
nonblock: Opens the specified socket handle for OVERLAPPED or
FIONBIO/`O_NONBLOCK` I/O usage. This is recommended for handles that
will be used by libuv, and not usually recommended otherwise.
pipe(2) with the O_CLOEXEC flag set. Example-- Simple read/write with pipe_open
local fds = uv.pipe({nonblock=true}, {nonblock=true})
local read_pipe = uv.new_pipe()
read_pipe:open(fds.read)
local write_pipe = uv.new_pipe()
write_pipe:open(fds.write)
write_pipe:write("hello")
read_pipe:read_start(function(err, chunk)
assert(not err, err)
print(chunk)
end)
{read_flags} ({ nonblock: boolean? }?)
{write_flags} ({ nonblock: boolean? }?)
uv.pipe.fds?) fds
(string?) err
(uv.error_name?) err_name
{pipe} (uv.uv_pipe_t)
{name} (string)
0?) success
(string?) err
(uv.error_name?) err_name
Flags:
type(flags) is number, it must be 0 or
uv.constants.PIPE_NO_TRUNCATE.
type(flags) is table, it must be {} or
{ no_truncate = true|false }.
type(flags) is nil, it use default value 0.
EINVAL for unsupported flags without performing the bind
operation.
{pipe} (uv.uv_pipe_t)
{name} (string)
{flags} (integer|table?)
0?) success
(string?) err
(uv.error_name?) err_name
flags
are: "r", "w", "rw", or "wr" where r is READABLE and w is
WRITABLE. This function is blocking.
{pipe} (uv.uv_pipe_t)
{flags} (string)
0?) success
(string?) err
(uv.error_name?) err_name
{pipe} (uv.uv_pipe_t)
{name} (string)
{callback} (fun(err: string?)?)
uv.uv_connect_t?) connect
(string?) err
(uv.error_name?) err_name
Flags:
type(flags) is number, it must be 0 or
uv.constants.PIPE_NO_TRUNCATE.
type(flags) is table, it must be {} or
{ no_truncate = true|false }.
type(flags) is nil, it use default value 0.
EINVAL for unsupported flags without performing the bind
operation.
{pipe} (uv.uv_pipe_t)
{name} (string)
{flags} (integer|table?)
{callback} (fun(err: string?)?)
uv.uv_connect_t?) connect
(string?) err
(uv.error_name?) err_name
{pipe})uv.pipe_getpeername(){pipe} (uv.uv_pipe_t)
string?) name
(string?) err
(uv.error_name?) err_name
{pipe})uv.pipe_getsockname(){pipe} (uv.uv_pipe_t)
string?) name
(string?) err
(uv.error_name?) err_name
{pipe} (uv.uv_pipe_t)
{fd} (integer)
0?) success
(string?) err
(uv.error_name?) err_name
{pipe})uv.pipe_pending_count(){pipe} (uv.uv_pipe_t)
integer)
{pipe} (uv.uv_pipe_t)
{count} (integer)
{pipe})uv.pipe_pending_type()uv.pipe_pending_count(), if it's > 0 then initialize a
handle of the given type, returned by uv.pipe_pending_type() and call
uv.accept(pipe, handle).
{pipe} (uv.uv_pipe_t)
string)
{name})uv_pipe_t:bind(){name} (string)
0?) success
(string?) err
(uv.error_name?) err_name
Flags:
type(flags) is number, it must be 0 or
uv.constants.PIPE_NO_TRUNCATE.
type(flags) is table, it must be {} or
{ no_truncate = true|false }.
type(flags) is nil, it use default value 0.
EINVAL for unsupported flags without performing the bind
operation.
{name} (string)
{flags} (integer|table?)
0?) success
(string?) err
(uv.error_name?) err_name
{flags})uv_pipe_t:chmod()flags
are: "r", "w", "rw", or "wr" where r is READABLE and w is
WRITABLE. This function is blocking.
{flags} (string)
0?) success
(string?) err
(uv.error_name?) err_name
{name} (string)
{callback} (fun(err: string?)?)
uv.uv_connect_t?) connect
(string?) err
(uv.error_name?) err_name
Flags:
type(flags) is number, it must be 0 or
uv.constants.PIPE_NO_TRUNCATE.
type(flags) is table, it must be {} or
{ no_truncate = true|false }.
type(flags) is nil, it use default value 0.
EINVAL for unsupported flags without performing the bind
operation.
{name} (string)
{flags} (integer|table?)
{callback} (fun(err: string?)?)
uv.uv_connect_t?) connect
(string?) err
(uv.error_name?) err_name
string?) name
(string?) err
(uv.error_name?) err_name
string?) name
(string?) err
(uv.error_name?) err_name
{fd})uv_pipe_t:open(){fd} (integer)
0?) success
(string?) err
(uv.error_name?) err_name
integer)
{count})uv_pipe_t:pending_instances(){count} (integer)
uv.pipe_pending_count(), if it's > 0 then initialize a
handle of the given type, returned by uv.pipe_pending_type() and call
uv.accept(pipe, handle).
string)
uv_tty_t - TTY handle-- Simple echo program
local stdin = uv.new_tty(0, true)
local stdout = uv.new_tty(1, false)
stdin:read_start(function (err, data)
assert(not err, err)
if data then
stdout:write(data)
else
stdin:close()
stdout:close()
end
end)
{get_winsize} (fun(self: uv.uv_tty_t): integer?, integer|string, uv.error_name?)
See uv_tty_t:get_winsize().
{set_mode} (fun(self: uv.uv_tty_t, mode: string|integer): 0?, string?, uv.error_name?)
See uv_tty_t:set_mode().
{fd} (integer)
{readable} (boolean)
uv.uv_tty_t?) tty
(string?) err
(uv.error_name?) err_name
"supported" or
"unsupported".
ENOTSUP.
string?) state
(string?) err
(uv.error_name?) err_name
{tty})uv.tty_get_winsize(){tty} (uv.uv_tty_t)
integer?) width
(integer|string) height_or_err
(uv.error_name?) err_name
EBUSY if you call it when execution is inside
uv.tty_set_mode().
0?) success
(string?) err
(uv.error_name?) err_name
{tty} (uv.uv_tty_t)
{mode} (string|integer)
0?) success
(string?) err
(uv.error_name?) err_name
{state})uv.tty_set_vterm_state()"supported" or "unsupported".
{state} (string)
integer?) width
(integer|string) height_or_err
(uv.error_name?) err_name
{mode})uv_tty_t:set_mode(){mode} (string|integer)
0?) success
(string?) err
(uv.error_name?) err_name
uv_udp_t - UDP handle{ipv6only} (boolean?)
{linux_recverr} (boolean?)
{reuseaddr} (boolean?)
{reuseport} (boolean?)
{family} (string)
{ip} (string)
{port} (integer)
{bind} (fun(self: uv.uv_udp_t, host: string, port: number, flags: uv.udp_bind.flags?): 0?, string?, uv.error_name?)
See uv_udp_t:bind().
{connect} (fun(self: uv.uv_udp_t, host: string?, port: integer?): 0?, string?, uv.error_name?)
See uv_udp_t:connect().
{getpeername} (fun(self: uv.uv_udp_t): uv.socketinfo?, string?, uv.error_name?)
See uv_udp_t:getpeername().
{getsockname} (fun(self: uv.uv_udp_t): uv.socketinfo?, string?, uv.error_name?)
See uv_udp_t:getsockname().
{open} (fun(self: uv.uv_udp_t, fd: integer, flags: integer|{ reuseaddr: boolean?, reuseport: boolean? }?): 0?, string?, uv.error_name?)
See uv_udp_t:open().
{recv_start} (fun(self: uv.uv_udp_t, callback: uv.udp_recv_start.callback): 0?, string?, uv.error_name?)
See uv_udp_t:recv_start().
{send} (fun(self: uv.uv_udp_t, data: uv.buffer, host: string?, port: integer?, callback: fun(err: string?)?): 0?, string?, uv.error_name?)
See uv_udp_t:send().
{set_broadcast} (fun(self: uv.uv_udp_t, on: boolean): 0?, string?, uv.error_name?)
See uv_udp_t:set_broadcast().
{set_membership} (fun(self: uv.uv_udp_t, multicast_addr: string, interface_addr: string?, membership: string): 0?, string?, uv.error_name?)
See uv_udp_t:set_membership().
{set_multicast_interface} (fun(self: uv.uv_udp_t, interface_addr: string): 0?, string?, uv.error_name?)
See uv_udp_t:set_multicast_interface().
{set_multicast_loop} (fun(self: uv.uv_udp_t, on: boolean): 0?, string?, uv.error_name?)
See uv_udp_t:set_multicast_loop().
{set_multicast_ttl} (fun(self: uv.uv_udp_t, ttl: integer): 0?, string?, uv.error_name?)
See uv_udp_t:set_multicast_ttl().
{set_source_membership} (fun(self: uv.uv_udp_t, multicast_addr: string, interface_addr: string?, source_addr: string, membership: string): 0?, string?, uv.error_name?)
See uv_udp_t:set_source_membership().
{set_ttl} (fun(self: uv.uv_udp_t, ttl: integer): 0?, string?, uv.error_name?)
See uv_udp_t:set_ttl().
{try_send} (fun(self: uv.uv_udp_t, data: uv.buffer, host: string?, port: integer?): integer?, string?, uv.error_name?)
See uv_udp_t:try_send().
{try_send2} (fun(self: uv.uv_udp_t, messages: table<integer, { data: uv.buffer, addr: { ip: string, port: integer }? }>, flags: 0): integer?, string?, uv.error_name?)
See uv_udp_t:try_send2().
{flags})uv.new_udp()uv_udp_t. Returns the Lua userdata
wrapping it. The actual socket is created lazily.
family input values.
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).
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.
{flags} (string|integer|{ family: string|integer?, mmsgs: integer? }?)
uv.uv_udp_t?) udp
(string?) err
(uv.error_name?) err_name
flags are set with a
table with fields reuseaddr, ipv6only, linux_recverr, reuseport
equal to true or false.
reuseaddr: Indicates if SO_REUSEADDR will be set when binding the
handle. This sets the SO_REUSEPORT socket flag on the BSDs (except for
DragonFlyBSD), OS X, and other platforms where SO_REUSEPORTs don't have
the capability of load balancing, as the opposite of what reuseport
would do. On other Unix platforms, it sets the SO_REUSEADDR flag. What
that means is that multiple threads or processes can bind to the same
address without error (provided they all set the flag) but only the last
one to bind will receive any traffic, in effect "stealing" the port from
the previous listener.
ipv6only: Disables dual stack mode.
linux_recverr: Indicates if IP_RECVERR/IPV6_RECVERR will be set when
binding the handle. This sets IP_RECVERR for IPv4 and IPV6_RECVERR for
IPv6 UDP sockets on Linux. This stops the Linux kernel from suppressing
some ICMP error messages and enables full ICMP error reporting for
faster failover. This flag is no-op on platforms other than Linux.
reuseport: Indicates if SO_REUSEPORT will be set when binding the
handle. This sets the SO_REUSEPORT socket option on supported platforms.
Unlike reuseaddr, this flag will make multiple threads or processes
that are binding to the same address and port "share" the port, which
means incoming datagrams are distributed across the receiving sockets
among threads or processes. This flag is available only on Linux 3.9+,
DragonFlyBSD 3.6+, FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ for now.
Note: The flag linux_recverr is only supported with Libuv >= 1.42.0.
The flag reuseport is only supported with Libuv >= 1.49.0.
{udp} (uv.uv_udp_t)
{host} (string)
{port} (number)
{flags} (uv.udp_bind.flags?)
0?) success
(string?) err
(uv.error_name?) err_name
host and port must be provided together. Pass explicit nil for both
to disconnect the handle.
uv.udp_connect() on an already connected handle will
result in an EISCONN error. Trying to disconnect a handle that is not
connected will return an ENOTCONN error.
{udp} (uv.uv_udp_t)
{host} (string?)
{port} (integer?)
0?) success
(string?) err
(uv.error_name?) err_name
{udp})uv.udp_get_send_queue_count(){udp} (uv.uv_udp_t)
integer)
{udp})uv.udp_get_send_queue_size(){udp} (uv.uv_udp_t)
integer)
{udp})uv.udp_getpeername(){udp} (uv.uv_udp_t)
uv.socketinfo?) address
(string?) err
(uv.error_name?) err_name
{udp})uv.udp_getsockname(){udp} (uv.uv_udp_t)
uv.socketinfo?) address
(string?) err
(uv.error_name?) err_name
flags is only supported with Libuv >= 1.52.0.
{udp} (uv.uv_udp_t)
{fd} (integer)
{flags} (integer|{ reuseaddr: boolean?, reuseport: boolean? }?)
0?) success
(string?) err
(uv.error_name?) err_name
uv.udp_bind() it is bound to 0.0.0.0 (the "all interfaces" IPv4
address) and a random port number.
family output values.
{udp} (uv.uv_udp_t)
{callback} (uv.udp_recv_start.callback)
0?) success
(string?) err
(uv.error_name?) err_name
{udp})uv.udp_recv_stop(){udp} (uv.uv_udp_t)
0?) success
(string?) err
(uv.error_name?) err_name
uv.udp_bind() it will be bound to 0.0.0.0 (the "all interfaces"
IPv4 address) and a random port number.
host and port must be provided together. For a connected socket, pass
explicit nil for both.
{udp} (uv.uv_udp_t)
{data} (uv.buffer)
{host} (string?)
{port} (integer?)
{callback} (fun(err: string?)?)
0?) success
(string?) err
(uv.error_name?) err_name
{udp} (uv.uv_udp_t)
{on} (boolean)
0?) success
(string?) err
(uv.error_name?) err_name
{udp}, {multicast_addr}, {interface_addr}, {membership})uv.udp_set_membership()multicast_addr is multicast
address to set membership for. interface_addr is interface address.
membership can be the string "leave" or "join".
{udp} (uv.uv_udp_t)
{multicast_addr} (string)
{interface_addr} (string?)
{membership} (string)
0?) success
(string?) err
(uv.error_name?) err_name
{udp} (uv.uv_udp_t)
{interface_addr} (string)
0?) success
(string?) err
(uv.error_name?) err_name
{udp} (uv.uv_udp_t)
{on} (boolean)
0?) success
(string?) err
(uv.error_name?) err_name
ttl is an integer 1 through 255.
{udp} (uv.uv_udp_t)
{ttl} (integer)
0?) success
(string?) err
(uv.error_name?) err_name
{udp}, {multicast_addr}, {interface_addr}, {source_addr}, {membership})uv.udp_set_source_membership()multicast_addr is
multicast address to set membership for. interface_addr is interface
address. source_addr is source address. membership can be the string
"leave" or "join".
{udp} (uv.uv_udp_t)
{multicast_addr} (string)
{interface_addr} (string?)
{source_addr} (string)
{membership} (string)
0?) success
(string?) err
(uv.error_name?) err_name
ttl is an integer 1 through 255.
{udp} (uv.uv_udp_t)
{ttl} (integer)
0?) success
(string?) err
(uv.error_name?) err_name
uv.udp_send(), but won't queue a send request if it can't be
completed immediately.
host and port must be provided together. For a connected socket, pass
explicit nil for both.
{udp} (uv.uv_udp_t)
{data} (uv.buffer)
{host} (string?)
{port} (integer?)
integer?) bytes_sent
(string?) err
(uv.error_name?) err_name
uv.udp_try_send(), but can send multiple datagrams. Lightweight
abstraction around sendmmsg(2), with a sendmsg(2) fallback loop for
platforms that do not support the former. The udp handle must be fully
initialized, either from a uv.udp_bind call, another call that will bind
automatically (udp_send, udp_try_send, etc), or from uv.udp_connect.
messages should be an array-like table, where addr must be specified
if the udp has not been connected via udp_connect. Otherwise, addr
must be nil.
flags is reserved for future extension and must currently be nil or
0 or {}.
-- If client:connect(...) was not called
local addr = { ip = "127.0.0.1", port = 1234 }
client:try_send2({
{ data = "Message 1", addr = addr },
{ data = "Message 2", addr = addr },
})
-- If client:connect(...) was called
client:try_send2({
{ data = "Message 1" },
{ data = "Message 2" },
})
{udp} (uv.uv_udp_t)
{messages} (table<integer, { data: uv.buffer, addr: { ip: string, port: integer }? }>)
{flags} (0)
integer?) messages_sent
(string?) err
(uv.error_name?) err_name
flags are set with a
table with fields reuseaddr, ipv6only, linux_recverr, reuseport
equal to true or false.
reuseaddr: Indicates if SO_REUSEADDR will be set when binding the
handle. This sets the SO_REUSEPORT socket flag on the BSDs (except for
DragonFlyBSD), OS X, and other platforms where SO_REUSEPORTs don't have
the capability of load balancing, as the opposite of what reuseport
would do. On other Unix platforms, it sets the SO_REUSEADDR flag. What
that means is that multiple threads or processes can bind to the same
address without error (provided they all set the flag) but only the last
one to bind will receive any traffic, in effect "stealing" the port from
the previous listener.
ipv6only: Disables dual stack mode.
linux_recverr: Indicates if IP_RECVERR/IPV6_RECVERR will be set when
binding the handle. This sets IP_RECVERR for IPv4 and IPV6_RECVERR for
IPv6 UDP sockets on Linux. This stops the Linux kernel from suppressing
some ICMP error messages and enables full ICMP error reporting for
faster failover. This flag is no-op on platforms other than Linux.
reuseport: Indicates if SO_REUSEPORT will be set when binding the
handle. This sets the SO_REUSEPORT socket option on supported platforms.
Unlike reuseaddr, this flag will make multiple threads or processes
that are binding to the same address and port "share" the port, which
means incoming datagrams are distributed across the receiving sockets
among threads or processes. This flag is available only on Linux 3.9+,
DragonFlyBSD 3.6+, FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ for now.
Note: The flag linux_recverr is only supported with Libuv >= 1.42.0.
The flag reuseport is only supported with Libuv >= 1.49.0.
{host} (string)
{port} (number)
{flags} (uv.udp_bind.flags?)
0?) success
(string?) err
(uv.error_name?) err_name
host and port must be provided together. Pass explicit nil for both
to disconnect the handle.
uv.udp_connect() on an already connected handle will
result in an EISCONN error. Trying to disconnect a handle that is not
connected will return an ENOTCONN error.
{host} (string?)
{port} (integer?)
0?) success
(string?) err
(uv.error_name?) err_name
integer)
integer)
uv.socketinfo?) address
(string?) err
(uv.error_name?) err_name
uv.socketinfo?) address
(string?) err
(uv.error_name?) err_name
flags is only supported with Libuv >= 1.52.0.
{fd} (integer)
{flags} (integer|{ reuseaddr: boolean?, reuseport: boolean? }?)
0?) success
(string?) err
(uv.error_name?) err_name
{callback})uv_udp_t:recv_start()uv.udp_bind() it is bound to 0.0.0.0 (the "all interfaces" IPv4
address) and a random port number.
family output values.
{callback} (uv.udp_recv_start.callback)
0?) success
(string?) err
(uv.error_name?) err_name
0?) success
(string?) err
(uv.error_name?) err_name
uv.udp_bind() it will be bound to 0.0.0.0 (the "all interfaces"
IPv4 address) and a random port number.
host and port must be provided together. For a connected socket, pass
explicit nil for both.
{data} (uv.buffer)
{host} (string?)
{port} (integer?)
{callback} (fun(err: string?)?)
0?) success
(string?) err
(uv.error_name?) err_name
{on})uv_udp_t:set_broadcast(){on} (boolean)
0?) success
(string?) err
(uv.error_name?) err_name
multicast_addr is multicast
address to set membership for. interface_addr is interface address.
membership can be the string "leave" or "join".
{multicast_addr} (string)
{interface_addr} (string?)
{membership} (string)
0?) success
(string?) err
(uv.error_name?) err_name
{interface_addr})uv_udp_t:set_multicast_interface(){interface_addr} (string)
0?) success
(string?) err
(uv.error_name?) err_name
{on})uv_udp_t:set_multicast_loop(){on} (boolean)
0?) success
(string?) err
(uv.error_name?) err_name
{ttl})uv_udp_t:set_multicast_ttl()ttl is an integer 1 through 255.
{ttl} (integer)
0?) success
(string?) err
(uv.error_name?) err_name
{multicast_addr}, {interface_addr}, {source_addr}, {membership})uv_udp_t:set_source_membership()multicast_addr is
multicast address to set membership for. interface_addr is interface
address. source_addr is source address. membership can be the string
"leave" or "join".
{multicast_addr} (string)
{interface_addr} (string?)
{source_addr} (string)
{membership} (string)
0?) success
(string?) err
(uv.error_name?) err_name
{ttl})uv_udp_t:set_ttl()ttl is an integer 1 through 255.
{ttl} (integer)
0?) success
(string?) err
(uv.error_name?) err_name
uv.udp_send(), but won't queue a send request if it can't be
completed immediately.
host and port must be provided together. For a connected socket, pass
explicit nil for both.
{data} (uv.buffer)
{host} (string?)
{port} (integer?)
integer?) bytes_sent
(string?) err
(uv.error_name?) err_name
uv.udp_try_send(), but can send multiple datagrams. Lightweight
abstraction around sendmmsg(2), with a sendmsg(2) fallback loop for
platforms that do not support the former. The udp handle must be fully
initialized, either from a uv.udp_bind call, another call that will bind
automatically (udp_send, udp_try_send, etc), or from uv.udp_connect.
messages should be an array-like table, where addr must be specified
if the udp has not been connected via udp_connect. Otherwise, addr
must be nil.
flags is reserved for future extension and must currently be nil or
0 or {}.
-- If client:connect(...) was not called
local addr = { ip = "127.0.0.1", port = 1234 }
client:try_send2({
{ data = "Message 1", addr = addr },
{ data = "Message 2", addr = addr },
})
-- If client:connect(...) was called
client:try_send2({
{ data = "Message 1" },
{ data = "Message 2" },
})
{messages} (table<integer, { data: uv.buffer, addr: { ip: string, port: integer }? }>)
{flags} (0)
integer?) messages_sent
(string?) err
(uv.error_name?) err_name
uv_fs_event_t - FS Event handle{recursive} (boolean?)
{stat} (boolean?)
{watch_entry} (boolean?)
{getpath} (fun(self: uv.uv_fs_event_t): string?, string?, uv.error_name?)
See uv_fs_event_t:getpath().
{start} (fun(self: uv.uv_fs_event_t, path: string, flags: uv.fs_event_start.flags, callback: uv.fs_event_start.callback): 0?, string?, uv.error_name?)
See uv_fs_event_t:start().
{fs_event})uv.fs_event_getpath(){fs_event} (uv.uv_fs_event_t)
string?) path
(string?) err
(uv.error_name?) err_name
{fs_event} (uv.uv_fs_event_t)
{path} (string)
{flags} (uv.fs_event_start.flags)
{callback} (uv.fs_event_start.callback)
0?) success
(string?) err
(uv.error_name?) err_name
{fs_event})uv.fs_event_stop(){fs_event} (uv.uv_fs_event_t)
0?) success
(string?) err
(uv.error_name?) err_name
uv_fs_event_t. Returns the Lua userdata
wrapping it.
uv.uv_fs_event_t?) fs_event
(string?) err
(uv.error_name?) err_name
string?) path
(string?) err
(uv.error_name?) err_name
{path} (string)
{flags} (uv.fs_event_start.flags)
{callback} (uv.fs_event_start.callback)
0?) success
(string?) err
(uv.error_name?) err_name
0?) success
(string?) err
(uv.error_name?) err_name
uv_fs_poll_t - FS Poll handleuv_fs_event_t, fs poll handles use stat to detect when a file has
changed so they can work on file systems where fs event handles can't.
{getpath} (fun(self: uv.uv_fs_poll_t): string?, string?, uv.error_name?)
See uv_fs_poll_t:getpath().
{start} (fun(self: uv.uv_fs_poll_t, path: string, interval: integer, callback: uv.fs_poll_start.callback): 0?, string?, uv.error_name?)
See uv_fs_poll_t:start().
{fs_poll})uv.fs_poll_getpath(){fs_poll} (uv.uv_fs_poll_t)
string?) path
(string?) err
(uv.error_name?) err_name
path for changes every interval milliseconds.
{fs_poll} (uv.uv_fs_poll_t)
{path} (string)
{interval} (integer)
{callback} (uv.fs_poll_start.callback)
0?) success
(string?) err
(uv.error_name?) err_name
{fs_poll})uv.fs_poll_stop(){fs_poll} (uv.uv_fs_poll_t)
0?) success
(string?) err
(uv.error_name?) err_name
uv_fs_poll_t. Returns the Lua userdata
wrapping it.
uv.uv_fs_poll_t?) fs_poll
(string?) err
(uv.error_name?) err_name
string?) path
(string?) err
(uv.error_name?) err_name
path for changes every interval milliseconds.
{path} (string)
{interval} (integer)
{callback} (uv.fs_poll_start.callback)
0?) success
(string?) err
(uv.error_name?) err_name
0?) success
(string?) err
(uv.error_name?) err_name
uv_fs_t userdata and asynchronously execute its callback; if an error is
encountered, the first and only argument passed to the callback will be the
err error string; if the operation completes successfully, the first
argument will be nil and the remaining arguments will be the results of the
FS call.
readFile (with naive error
handling) are implemented below as an example:local function readFileSync(path)
local fd = assert(uv.fs_open(path, "r", 438))
local stat = assert(uv.fs_fstat(fd))
local data = assert(uv.fs_read(fd, stat.size, 0))
assert(uv.fs_close(fd))
return data
end
local data = readFileSync("main.lua")
print("synchronous read", data)
local function readFile(path, callback)
uv.fs_open(path, "r", 438, function(err, fd)
assert(not err, err)
uv.fs_fstat(fd, function(err, stat)
assert(not err, err)
uv.fs_read(fd, stat.size, 0, function(err, data)
assert(not err, err)
uv.fs_close(fd, function(err)
assert(not err, err)
return callback(data)
end)
end)
end)
end)
end
readFile("main.lua", function(data)
print("asynchronous read", data)
end)
{excl} (boolean?)
{ficlone} (boolean?)
{ficlone_force} (boolean?)
{atime} (uv.fs_stat.result.time)
{birthtime} (uv.fs_stat.result.time)
{blksize} (integer)
{blocks} (integer)
{ctime} (uv.fs_stat.result.time)
{dev} (integer)
{flags} (integer)
{gen} (integer)
{gid} (integer)
{ino} (integer)
{mode} (integer)
{mtime} (uv.fs_stat.result.time)
{nlink} (integer)
{rdev} (integer)
{size} (integer)
{type} (string?)
{uid} (integer)
{nsec} (integer)
{sec} (integer)
{bavail} (integer)
{bfree} (integer)
{blocks} (integer)
{bsize} (integer)
{ffree} (integer)
{files} (integer)
{frsize} (integer?)
{type} (integer)
userdata
{closedir} (fun(self: uv.luv_dir_t, callback: nil?): boolean?, string?, uv.error_name?)
See luv_dir_t:closedir().
{readdir} (fun(self: uv.luv_dir_t, callback: nil?): table<integer, { name: string, type: string? }>?, string?, uv.error_name?)
See luv_dir_t:readdir().
{callback})luv_dir_t:closedir()uv.fs_opendir() call.
{callback} (nil?) (async if provided, sync if nil)
fun(self: uv.luv_dir_t, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
{callback})luv_dir_t:readdir()luv_dir_t returned by a successful
uv.fs_opendir() call. A table of data tables is returned where the
number of entries n is equal to or less than the entries parameter
used in the associated uv.fs_opendir() call.
{callback} (nil?) (async if provided, sync if nil)
fun(self: uv.luv_dir_t, callback: fun(err: string?, entries: table<integer, { name: string, type: string? }>?)): uv.uv_fs_t?, string?, uv.error_name?
table<integer, { name: string, type: string? }>?) entries
(string?) err
(uv.error_name?) err_name
access(2) on Unix. Windows uses GetFileAttributesW().
Access mode can be an integer or a string containing "R" or "W" or
"X". Returns true or false indicating access permission.
{path} (string)
{mode} (string|integer) (a combination of the 'r', 'w' and
'x' characters denoting the symbolic mode as per
chmod(1))
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, mode: string|integer, callback: fun(err: string?, permission: boolean?)): uv.uv_fs_t
boolean?) permission
(string?) err
(uv.error_name?) err_name
chmod(2).
{path} (string)
{mode} (integer) (octal chmod(1) mode, e.g.
tonumber('644', 8))
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, mode: integer, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
chown(2).
{path} (string)
{uid} (integer)
{gid} (integer)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, uid: integer, gid: integer, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
close(2).
{fd} (integer)
{callback} (nil?) (async if provided, sync if nil)
fun(fd: integer, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
uv.fs_opendir() call.
{dir} (uv.luv_dir_t)
{callback} (nil?) (async if provided, sync if nil)
fun(dir: uv.luv_dir_t, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
flags parameter is omitted,
then the 3rd parameter will be treated as the callback.
{path} (string)
{new_path} (string)
{flags} (integer|uv.fs_copyfile.flags?)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, new_path: string, flags: integer|uv.fs_copyfile.flags?, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
fun(path: string, new_path: string, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
fchmod(2).
{fd} (integer)
{mode} (integer)
{callback} (nil?) (async if provided, sync if nil)
fun(fd: integer, mode: integer, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
fchown(2).
{fd} (integer)
{uid} (integer)
{gid} (integer)
{callback} (nil?) (async if provided, sync if nil)
fun(fd: integer, uid: integer, gid: integer, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
fdatasync(2).
{fd} (integer)
{callback} (nil?) (async if provided, sync if nil)
fun(fd: integer, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
fstat(2).
{fd} (integer)
{callback} (nil?) (async if provided, sync if nil)
fun(fd: integer, callback: fun(err: string?, stat: uv.fs_stat.result?)): uv.uv_fs_t?, string?, uv.error_name?
uv.fs_stat.result?) stat
(string?) err
(uv.error_name?) err_name
fsync(2).
{fd} (integer)
{callback} (nil?) (async if provided, sync if nil)
fun(fd: integer, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
ftruncate(2).
{fd} (integer)
{offset} (integer)
{callback} (nil?) (async if provided, sync if nil)
fun(fd: integer, offset: integer, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
futimes(3).
"now" or uv.constants.FS_UTIME_NOW as the atime or mtime sets
the timestamp to the current time.
nil, "omit", or uv.constants.FS_UTIME_OMIT as the atime or
mtime leaves the timestamp untouched.
{fd} (integer)
{atime} (number|string?)
{mtime} (number|string?)
{callback} (nil?) (async if provided, sync if nil)
fun(fd: integer, atime: number|string?, mtime: number|string?, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
lchown(2).
{path} (string)
{uid} (integer)
{gid} (integer)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, uid: integer, gid: integer, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
link(2).
{path} (string)
{new_path} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, new_path: string, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
lstat(2).
{path} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, callback: fun(err: string?, stat: uv.fs_stat.result?)): uv.uv_fs_t?, string?, uv.error_name?
uv.fs_stat.result?) stat
(string?) err
(uv.error_name?) err_name
lutimes(3).
"now" or uv.constants.FS_UTIME_NOW as the atime or mtime sets
the timestamp to the current time.
nil, "omit", or uv.constants.FS_UTIME_OMIT as the atime or
mtime leaves the timestamp untouched.
{path} (string)
{atime} (number|string?)
{mtime} (number|string?)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, atime: number|string?, mtime: number|string?, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
mkdir(2).
{path} (string)
{mode} (integer) (octal chmod(1) mode, e.g.
tonumber('755', 8))
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, mode: integer, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
mkdtemp(3).
{template} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(template: string, callback: fun(err: string?, path: string?)): uv.uv_fs_t?, string?, uv.error_name?
string?) path
(string?) err
(uv.error_name?) err_name
mkstemp(3). Returns a temporary file handle and filename.
{template} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(template: string, callback: uv.fs_mkstemp.callback): uv.uv_fs_t?, string?, uv.error_name?
integer?) fd
(string) path_or_err
(uv.error_name?) err_name
open(2). Access flags may be an integer or one of:
"r", "rs", "sr", "r+", "rs+", "sr+", "w", "wx", "xw",
"w+", "wx+", "xw+", "a", "ax", "xa", "a+", "ax+", or
"`xa+`". Note: On Windows, libuv uses CreateFileW and thus the file is
always opened in binary mode. Because of this, the O_BINARY and O_TEXT
flags are not supported.
{path} (string)
{flags} (string|integer)
{mode} (integer) (octal chmod(1) mode, e.g.
tonumber('644', 8))
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, flags: string|integer, mode: integer, callback: fun(err: string?, fd: integer?)): uv.uv_fs_t?, string?, uv.error_name?
integer?) fd
(string?) err
(uv.error_name?) err_name
uv.fs_readdir(). The entries parameter defines the maximum number
of entries that should be returned by each call to uv.fs_readdir().
{path} (string)
{callback} (nil?) (async if provided, sync if nil)
{entries} (integer?)
fun(path: string, callback: fun(err: string?, dir: uv.luv_dir_t?), entries: integer?): uv.uv_fs_t?, string?, uv.error_name?
uv.luv_dir_t?) dir
(string?) err
(uv.error_name?) err_name
preadv(2). Returns any data. An empty string indicates
EOF.
offset is nil or omitted, it will default to -1, which indicates
"use and update the current file offset."
offset is >= 0, the current file offset will not be updated
by the read.
{fd} (integer)
{size} (integer)
{offset} (integer?)
{callback} (nil?) (async if provided, sync if nil)
fun(fd: integer, size: integer, offset: integer?, callback: fun(err: string?, data: string?)): uv.uv_fs_t?, string?, uv.error_name?
fun(fd: integer, size: integer, callback: fun(err: string?, data: string?)): uv.uv_fs_t?, string?, uv.error_name?
string?) data
(string?) err
(uv.error_name?) err_name
luv_dir_t returned by a successful
uv.fs_opendir() call. A table of data tables is returned where the
number of entries n is equal to or less than the entries parameter
used in the associated uv.fs_opendir() call.
{dir} (uv.luv_dir_t)
{callback} (nil?) (async if provided, sync if nil)
fun(dir: uv.luv_dir_t, callback: fun(err: string?, entries: table<integer, { name: string, type: string? }>?)): uv.uv_fs_t?, string?, uv.error_name?
table<integer, { name: string, type: string? }>?) entries
(string?) err
(uv.error_name?) err_name
readlink(2).
{path} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, callback: fun(err: string?, path: string?)): uv.uv_fs_t?, string?, uv.error_name?
string?) path
(string?) err
(uv.error_name?) err_name
realpath(3).
{path} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, callback: fun(err: string?, path: string?)): uv.uv_fs_t?, string?, uv.error_name?
string?) path
(string?) err
(uv.error_name?) err_name
rename(2).
{path} (string)
{new_path} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, new_path: string, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
rmdir(2).
{path} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
scandir(3), with a slightly different API. Returns a
handle that the user can pass to uv.fs_scandir_next().
{path} (string)
{callback} (fun(err: string?, success: uv.uv_fs_t?)?)
uv.uv_fs_t?) handle
(string?) err
(uv.error_name?) err_name
{fs})uv.fs_scandir_next()uv_fs_t returned by uv.fs_scandir() to get the next
directory entry data as a name, type pair. When there are no more
entries, nil is returned.
uv.fs_opendir
and its related functions for an asynchronous version.
{fs} (uv.uv_fs_t)
string?) name
(string?) type_or_err
(uv.error_name?) err_name
sendfile(2). Returns the number of bytes written.
{out_fd} (integer)
{in_fd} (integer)
{in_offset} (integer)
{size} (integer)
{callback} (nil?) (async if provided, sync if nil)
fun(out_fd: integer, in_fd: integer, in_offset: integer, size: integer, callback: fun(err: string?, bytes: integer?)): uv.uv_fs_t?, string?, uv.error_name?
integer?) bytes
(string?) err
(uv.error_name?) err_name
stat(2).
{path} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, callback: fun(err: string?, stat: uv.fs_stat.result?)): uv.uv_fs_t?, string?, uv.error_name?
uv.fs_stat.result?) stat
(string?) err
(uv.error_name?) err_name
statfs(2).
{path} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, callback: fun(err: string?, stat: uv.fs_statfs.result?)): uv.uv_fs_t?, string?, uv.error_name?
uv.fs_statfs.result?) stat
(string?) err
(uv.error_name?) err_name
symlink(2). If the flags parameter is omitted, then the
3rd parameter will be treated as the callback.
{path} (string)
{new_path} (string)
{flags} (integer|{ dir: boolean?, junction: boolean? }?)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, new_path: string, flags: integer|{ dir: boolean?, junction: boolean? }?, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
fun(path: string, new_path: string, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
unlink(2).
{path} (string)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
utime(2).
"now" or uv.constants.FS_UTIME_NOW as the atime or mtime sets
the timestamp to the current time.
nil, "omit", or uv.constants.FS_UTIME_OMIT as the atime or
mtime leaves the timestamp untouched.
{path} (string)
{atime} (number|string?)
{mtime} (number|string?)
{callback} (nil?) (async if provided, sync if nil)
fun(path: string, atime: number|string?, mtime: number|string?, callback: fun(err: string?, success: boolean?)): uv.uv_fs_t?, string?, uv.error_name?
boolean?) success
(string?) err
(uv.error_name?) err_name
pwritev(2). Returns the number of bytes written.
offset is nil or omitted, it will default to -1, which indicates
"use and update the current file offset."
offset is >= 0, the current file offset will not be updated
by the write.
{fd} (integer)
{data} (uv.buffer)
{offset} (integer?)
{callback} (nil?) (async if provided, sync if nil)
fun(fd: integer, data: uv.buffer, offset: integer?, callback: fun(err: string?, bytes: integer?)): uv.uv_fs_t?, string?, uv.error_name?
fun(fd: integer, data: uv.buffer, callback: fun(err: string?, bytes: integer?)): uv.uv_fs_t?, string?, uv.error_name?
integer?) bytes_written
(string?) err
(uv.error_name?) err_name
getaddrinfo and getnameinfo requests.local function work_callback(a, b)
return a + b
end
local function after_work_callback(c)
print("The result is: " .. c)
end
local work = uv.new_work(work_callback, after_work_callback)
work:queue(1, 2)
-- output: "The result is: 3"
userdata
{queue} (fun(self: uv.luv_work_ctx_t, ...: uv.threadargs): boolean?, string?, uv.error_name?)
See luv_work_ctx_t:queue().
{...})luv_work_ctx_t:queue()work_callback in a new Lua state in
a thread from the threadpool with any additional arguments from ....
Values returned from work_callback are passed to after_work_callback,
which is called in the main loop thread.
{...} (uv.threadargs)
boolean?) success
(string?) err
(uv.error_name?) err_name
luv_work_ctx_t (not uv_work_t).
work_callback is a Lua function or a string containing Lua code or
bytecode dumped from a function. Returns the Lua userdata wrapping it.
{work_callback} (string|fun(...: uv.threadargs))
{after_work_callback} (fun(...: uv.threadargs))
uv.luv_work_ctx_t)
work_callback in a new Lua state in
a thread from the threadpool with any additional arguments from ....
Values returned from work_callback are passed to after_work_callback,
which is called in the main loop thread.
{work_ctx} (uv.luv_work_ctx_t)
{...} (uv.threadargs)
boolean?) success
(string?) err
(uv.error_name?) err_name
{addrconfig} (boolean?)
{all} (boolean?)
{canonname} (boolean?)
{family} (string|integer?)
{numerichost} (boolean?)
{numericserv} (boolean?)
{passive} (boolean?)
{protocol} (string|integer?)
{socktype} (string|integer?)
{v4mapped} (boolean?)
{family} (string|integer?)
{ip} (string?)
{port} (integer?)
getaddrinfo(3). Either node or service may be nil
but not both.
family input and output
values.
socktype input and output values.
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.
{node} (string?)
{service} (string?)
{hints} (uv.getaddrinfo.hints?)
{callback} (nil?) (async if provided, sync if nil)
fun(node: string?, service: string?, hints: uv.getaddrinfo.hints?, callback: fun(err: string?, addresses: table<integer, uv.address>?)): uv.uv_getaddrinfo_t?, string?, uv.error_name?
table<integer, uv.address>?) addresses
(string?) err
(uv.error_name?) err_name
getnameinfo(3).
family input values.
{address} (uv.getnameinfo.address)
{callback} (nil?) (async if provided, sync if nil)
fun(address: uv.getnameinfo.address, callback: uv.getnameinfo.callback): uv.uv_getnameinfo_t?, string?, uv.error_name?
string?) host
(string) service_or_err
(uv.error_name?) err_name
userdata
userdata
{equal} (fun(self: uv.luv_thread_t, other_thread: uv.luv_thread_t): boolean)
See luv_thread_t:equal().
{getaffinity} (fun(self: uv.luv_thread_t, mask_size: integer?): table<integer, boolean>?, string?, uv.error_name?)
See luv_thread_t:getaffinity().
{getname} (fun(self: uv.luv_thread_t): string?, string?, uv.error_name?)
See luv_thread_t:getname().
{getpriority} (fun(self: uv.luv_thread_t): integer?, string?, uv.error_name?)
See luv_thread_t:getpriority().
{setaffinity} (fun(self: uv.luv_thread_t, affinity: table<integer, boolean>, get_old_affinity: boolean?): table<integer, boolean>|boolean?, string?, uv.error_name?)
See luv_thread_t:setaffinity().
{setpriority} (fun(self: uv.luv_thread_t, priority: integer): boolean?, string?, uv.error_name?)
See luv_thread_t:setpriority().
uv.sem_wait() but returns immediately if the semaphore is
not available.
true is returned,
otherwise the semaphore has a value of zero and false is returned.
boolean)
uv.thread_join.
boolean?) success
(string?) err
(uv.error_name?) err_name
{other_thread})luv_thread_t:equal()__eq metamethod.
{other_thread} (uv.luv_thread_t)
boolean)
{mask_size})luv_thread_t:getaffinity()mask_size is provided, it must be greater than or equal to
uv.cpumask_size(). If the mask_size parameter is omitted, then the
return of uv.cpumask_size() will be used. Returns an array-like table
where each of the keys correspond to a CPU number and the values are
booleans that represent whether the thread is eligible to run on that
CPU.
{mask_size} (integer?)
table<integer, boolean>?) affinity
(string?) err
(uv.error_name?) err_name
thread.
string?) name
(string?) err
(uv.error_name?) err_name
integer?) priority
(string?) err
(uv.error_name?) err_name
thread to finish executing its entry function.
boolean?) success
(string?) err
(uv.error_name?) err_name
affinity must be a table where each of the keys are a CPU number and the
values are booleans that represent whether the thread should be eligible
to run on that CPU. If the length of the affinity table is not greater
than or equal to uv.cpumask_size(), any CPU numbers missing from the
table will have their affinity set to false. If setting the affinity of
more than uv.cpumask_size() CPUs is desired, affinity must be an
array-like table with no gaps, since #affinity will be used as the
cpumask_size if it is greater than uv.cpumask_size().
get_old_affinity is true, the previous affinity settings for the
thread will be returned. Otherwise, true is returned after a
successful call.
{affinity} (table<integer, boolean>)
{get_old_affinity} (boolean?)
table<integer, boolean>|boolean?) affinity_or_success
(string?) err
(uv.error_name?) err_name
{priority})luv_thread_t:setpriority(){priority} (integer)
boolean?) success
(string?) err
(uv.error_name?) err_name
{value})uv.new_sem()uv.sem_wait() on a single thread that
blocks will deadlock.
{value} (integer?)
uv.luv_sem_t?) sem
(string?) err
(uv.error_name?) err_name
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 bytecode dumped
from a function. Additional arguments ... are passed to the entry
function and an optional options table may be provided. Currently
accepted option fields are stack_size. Note: unsafe, please make sure
the thread end of life before Lua state close.
{options} ({ stack_size: integer? })
{entry} (function|string)
{...} (uv.threadargs) passed to entry
fun(entry: function|string, ...: uv.threadargs): uv.luv_thread_t?, string?, uv.error_name?
uv.luv_thread_t?) thread
(string?) err
(uv.error_name?) err_name
{sem})uv.sem_post(){sem} (uv.luv_sem_t)
{sem})uv.sem_trywait()uv.sem_wait() but returns immediately if the semaphore is
not available.
true is returned,
otherwise the semaphore has a value of zero and false is returned.
{sem} (uv.luv_sem_t)
boolean)
{sem})uv.sem_wait(){sem} (uv.luv_sem_t)
{msec})uv.sleep(){msec} (integer)
{thread})uv.thread_detach()uv.thread_join.
{thread} (uv.luv_thread_t)
boolean?) success
(string?) err
(uv.error_name?) err_name
__eq metamethod.
{thread} (uv.luv_thread_t)
{other_thread} (uv.luv_thread_t)
boolean)
mask_size is provided, it must be greater than or equal to
uv.cpumask_size(). If the mask_size parameter is omitted, then the
return of uv.cpumask_size() will be used. Returns an array-like table
where each of the keys correspond to a CPU number and the values are
booleans that represent whether the thread is eligible to run on that
CPU.
{thread} (uv.luv_thread_t)
{mask_size} (integer?)
table<integer, boolean>?) affinity
(string?) err
(uv.error_name?) err_name
uv.thread_getaffinity and uv.thread_setaffinity.
integer?) cpu
(string?) err
(uv.error_name?) err_name
{thread})uv.thread_getname()thread.
{thread} (uv.luv_thread_t)
string?) name
(string?) err
(uv.error_name?) err_name
{thread})uv.thread_getpriority(){thread} (uv.luv_thread_t)
integer?) priority
(string?) err
(uv.error_name?) err_name
{thread})uv.thread_join()thread to finish executing its entry function.
{thread} (uv.luv_thread_t)
boolean?) success
(string?) err
(uv.error_name?) err_name
uv.luv_thread_t)
affinity must be a table where each of the keys are a CPU number and the
values are booleans that represent whether the thread should be eligible
to run on that CPU. If the length of the affinity table is not greater
than or equal to uv.cpumask_size(), any CPU numbers missing from the
table will have their affinity set to false. If setting the affinity of
more than uv.cpumask_size() CPUs is desired, affinity must be an
array-like table with no gaps, since #affinity will be used as the
cpumask_size if it is greater than uv.cpumask_size().
get_old_affinity is true, the previous affinity settings for the
thread will be returned. Otherwise, true is returned after a
successful call.
{thread} (uv.luv_thread_t)
{affinity} (table<integer, boolean>)
{get_old_affinity} (boolean?)
table<integer, boolean>|boolean?) affinity_or_success
(string?) err
(uv.error_name?) err_name
{name})uv.thread_setname()name is larger than the limit of the platform.
{name} (string)
0?) success
(string?) err
(uv.error_name?) err_name
{thread} (uv.luv_thread_t)
{priority} (integer)
boolean?) success
(string?) err
(uv.error_name?) err_name
{model} (string)
{speed} (integer)
{times} (uv.cpu_info.cpu_info.times)
{idle} (integer)
{irq} (integer)
{nice} (integer)
{sys} (integer)
{user} (integer)
{idrss} (integer) (integral unshared data size)
{inblock} (integer) (block input operations)
{isrss} (integer) (integral unshared stack size)
{ixrss} (integer) (integral shared memory size)
{majflt} (integer) (page faults (hard page faults))
{maxrss} (integer) (maximum resident set size)
{minflt} (integer) (page reclaims (soft page faults))
{msgrcv} (integer) (IPC messages received)
{msgsnd} (integer) (IPC messages sent)
{nivcsw} (integer) (involuntary context switches)
{nsignals} (integer) (signals received)
{nswap} (integer) (swaps)
{nvcsw} (integer) (voluntary context switches)
{oublock} (integer) (block output operations)
{stime} (uv.getrusage.result.time) (system CPU time used)
{utime} (uv.getrusage.result.time) (user CPU time used)
{sec} (integer)
{usec} (integer)
{family} (string)
{internal} (boolean)
{ip} (string)
{mac} (string)
{netmask} (string)
{gid} (integer?) (nil on Windows)
{homedir} (string)
{shell} (string?) (nil on Windows)
{uid} (integer?) (nil on Windows)
{username} (string)
{machine} (string)
{release} (string)
{sysname} (string)
{version} (string)
integer)
{cwd})uv.chdir()cwd.
{cwd} (string)
0?) success
(string?) err
(uv.error_name?) err_name
{clock_id})uv.clock_gettime()clock_id can be the string "monotonic" or
"realtime".
{clock_id} (string)
{ sec: integer, nsec: integer }?) time
(string?) err
(uv.error_name?) err_name
table<integer, uv.cpu_info.cpu_info>?) cpu_info
(string?) err
(uv.error_name?) err_name
ENOTSUP if affinities are not supported on the current platform.
integer?) size
(string?) err
(uv.error_name?) err_name
string?) path
(string?) err
(uv.error_name?) err_name
string?) path
(string?) err
(uv.error_name?) err_name
uv.get_free_memory() in that it takes into
account any limits imposed by the OS. If there is no such constraint, or
the constraint is unknown, the amount returned will be identical to
uv.get_free_memory().
number)
number)
number)
string?) title
(string?) err
(uv.error_name?) err_name
number)
integer)
uv.getrusage.result?) rusage
(string?) err
(uv.error_name?) err_name
ENOTSUP. On macOS and
Windows not all fields are set (the unsupported fields are filled with
zeroes).
uv.getrusage.result?) rusage
(string?) err
(uv.error_name?) err_name
gettimeofday(2). Returns the seconds
and microseconds of a unix time as a pair.
integer?) seconds
(integer|string) microseconds_or_err
(uv.error_name?) err_name
integer)
{fd})uv.guess_handle()fd. Usually this will be used during initialization to guess
the type of the stdio streams.
{fd} (integer)
string)
integer)
{ifindex})uv.if_indextoiid()ifindex as a string. On
all other platforms, uv.if_indextoname() is used.
{ifindex} (integer)
string?) iid
(string?) err
(uv.error_name?) err_name
{ifindex})uv.if_indextoname()if_indextoname(3).
{ifindex} (integer)
string?) name
(string?) err
(uv.error_name?) err_name
ip, family,
netmask, internal, and mac.
family output values.
table<string, table<integer, uv.interface_addresses.addresses>>?)
addresses
(string?) err
(uv.error_name?) err_name
number)
(number)
(number)
table<string, string>?) env
(string?) err
(uv.error_name?) err_name
uid, gid, and shell are set to
nil.
uv.os_get_passwd.passwd?) passwd
(string?) err
(uv.error_name?) err_name
name as string. The
internal buffer size can be set by defining size. If omitted,
LUAL_BUFFERSIZE is used. If the environment variable exceeds the storage
available in the internal buffer, ENOBUFS is returned. If no matching
environment variable exists, ENOENT is returned. Warning: This function
is not thread-safe.
{name} (string)
{size} (integer?)
string?) value
(string?) err
(uv.error_name?) err_name
string?) hostname
(string?) err
(uv.error_name?) err_name
number)
number)
{pid})uv.os_getpriority()pid.
{pid} (integer)
integer?) priority
(string?) err
(uv.error_name?) err_name
string?) path
(string?) err
(uv.error_name?) err_name
name with the string
value. Warning: This function is not thread-safe.
{name} (string)
{value} (string)
boolean?) success
(string?) err
(uv.error_name?) err_name
pid. The
priority range is between -20 (high priority) and 19 (low priority).
{pid} (integer)
{priority} (integer)
boolean?) success
(string?) err
(uv.error_name?) err_name
string?) path
(string?) err
(uv.error_name?) err_name
uv.os_uname.info?) info
(string?) err
(uv.error_name?) err_name
{name})uv.os_unsetenv()name. Warning: This
function is not thread-safe.
{name} (string)
boolean?) success
(string?) err
(uv.error_name?) err_name
uv.print_all_handles() except only active handles are
printed. Note: This is not available on Windows. Warning: This function is
meant for ad hoc debugging, there are no API/ABI stability guarantees.
[flags] handle-type handle-address. Flags are R for referenced, A
for active and I for internal. Note: This is not available on Windows.
Warning: This function is meant for ad hoc debugging, there are no API/ABI
stability guarantees.
len with cryptographically strong random bytes
acquired from the system CSPRNG. flags is reserved for future extension
and must currently be nil or 0 or {}.
len random bytes are
available, a non-zero error value is returned or passed to the callback.
If the callback is omitted, this function is completed synchronously.
{len} (integer)
{flags} (0)
{callback} (nil?) (async if provided, sync if nil)
fun
string?) bytes
(string?) err
(uv.error_name?) err_name
integer?) rss
(string?) err
(uv.error_name?) err_name
{title})uv.set_process_title()title.
{title} (string)
0?) success
(string?) err
(uv.error_name?) err_name
{id})uv.setgid()id. Note: This is not
a libuv function and is not supported on Windows.
{id} (integer)
{id})uv.setuid()id. Note: This is not a
libuv function and is not supported on Windows.
{id} (integer)
{errcode})uv.translate_sys_error(){errcode} (integer)
string?) message
(string?) name
number?) uptime
(string?) err
(uv.error_name?) err_name
{events} (integer)
{events_waiting} (integer)
{loop_count} (integer)
epoll_wait). The call is thread safe.
loop_configure with "metrics_idle_time".
number)
prepare callback (see
uv.new_prepare, uv.prepare_start) in order to make sure there are no
inconsistencies with the metrics counters.
uv.metrics_info.info?) info
(string?) err
(uv.error_name?) err_name
{addr} (string)
{canonname} (string?)
{family} (string)
{port} (integer?)
{protocol} (string)
{socktype} (string)
{family} (string)
{ip} (string)
{port} (integer)
{utf16})uv.utf16_length_as_wtf8()utf16 value
after converting it to WTF-8.
{utf16} (string)
integer)
{utf16})uv.utf16_to_wtf8()utf16 to WTF-8 string. The endianness
of the UTF-16 (or UCS-2) string is assumed to be the same as the native
endianness of the platform.
{utf16} (string)
string?) wtf8
(string?) err
(uv.error_name?) err_name
{wtf8})uv.wtf8_length_as_utf16()wtf8 value after
converting it to UTF-16 (or UCS-2). Note: The number of bytes needed for a
UTF-16 (or UCS-2) string is <number of code units> * 2.
{wtf8} (string)
integer)
{wtf8})uv.wtf8_to_utf16()wtf8 to UTF-16 (or UCS-2) string. The endianness
of the UTF-16 (or UCS-2) string will be the same as the native endianness
of the platform.
{wtf8} (string)
string)