libuv 1.42.0.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3650 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2021-07-27 22:08:18 +00:00
parent 5197eb91f7
commit da51e87774
183 changed files with 4013 additions and 1768 deletions

View File

@ -69,8 +69,8 @@ int main() {
hints.ai_flags = 0;
uv_getaddrinfo_t resolver;
fprintf(stderr, "irc.freenode.net is... ");
int r = uv_getaddrinfo(loop, &resolver, on_resolved, "irc.freenode.net", "6667", &hints);
fprintf(stderr, "irc.libera.chat is... ");
int r = uv_getaddrinfo(loop, &resolver, on_resolved, "irc.libera.chat", "6667", &hints);
if (r) {
fprintf(stderr, "getaddrinfo call error %s\n", uv_err_name(r));

42
deps/libuv/docs/requirements.txt vendored Normal file
View File

@ -0,0 +1,42 @@
# primary
Sphinx==3.5.4
# dependencies
alabaster==0.7.12
appdirs==1.4.3
Babel==2.9.0
CacheControl==0.12.6
certifi==2019.11.28
chardet==3.0.4
colorama==0.4.3
contextlib2==0.6.0
distlib==0.3.0
distro==1.4.0
docutils==0.16
html5lib==1.0.1
idna==2.8
imagesize==1.2.0
ipaddr==2.2.0
Jinja2==2.11.3
lockfile==0.12.2
MarkupSafe==1.1.1
msgpack==0.6.2
packaging==20.3
pep517==0.8.2
progress==1.5
Pygments==2.8.1
pyparsing==2.4.6
pytoml==0.1.21
pytz==2021.1
requests==2.22.0
retrying==1.3.3
six==1.14.0
snowballstemmer==2.1.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
urllib3==1.25.8
webencodings==0.5.1

View File

@ -251,6 +251,10 @@ Error constants
operation not supported on socket
.. c:macro:: UV_EOVERFLOW
value too large for defined data type
.. c:macro:: UV_EPERM
operation not permitted
@ -331,6 +335,10 @@ Error constants
illegal byte sequence
.. c:macro:: UV_ESOCKTNOSUPPORT
socket type not supported
API
---

View File

@ -87,6 +87,7 @@ nothing, except start a loop which will exit immediately.
.. rubric:: helloworld/main.c
.. literalinclude:: ../../code/helloworld/main.c
:language: c
:linenos:
This program quits immediately because it has no events to process. A libuv
@ -202,6 +203,7 @@ event watchers are active.
.. rubric:: idle-basic/main.c
.. literalinclude:: ../../code/idle-basic/main.c
:language: c
:emphasize-lines: 6,10,14-17
Storing context

View File

@ -20,6 +20,7 @@ these things can be a bit difficult to understand, so let's look at
.. rubric:: src/unix/core.c - uv_run
.. literalinclude:: ../../../src/unix/core.c
:language: c
:linenos:
:lines: 304-324
:emphasize-lines: 10,19,21
@ -43,6 +44,7 @@ iteration of the loop still takes places.
.. rubric:: uvstop/main.c
.. literalinclude:: ../../code/uvstop/main.c
:language: c
:linenos:
:emphasize-lines: 11

View File

@ -54,6 +54,7 @@ a callback for when the file is opened:
.. rubric:: uvcat/main.c - opening a file
.. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos:
:lines: 41-53
:emphasize-lines: 4, 6-7
@ -63,6 +64,7 @@ The ``result`` field of a ``uv_fs_t`` is the file descriptor in case of the
.. rubric:: uvcat/main.c - read callback
.. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos:
:lines: 26-40
:emphasize-lines: 2,8,12
@ -87,6 +89,7 @@ callbacks.
.. rubric:: uvcat/main.c - write callback
.. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos:
:lines: 16-24
:emphasize-lines: 6
@ -100,6 +103,7 @@ We set the dominos rolling in ``main()``:
.. rubric:: uvcat/main.c
.. literalinclude:: ../../code/uvcat/main.c
:language: c
:linenos:
:lines: 55-
:emphasize-lines: 2
@ -203,6 +207,7 @@ opened as bidirectional by default.
.. rubric:: uvtee/main.c - read on pipes
.. literalinclude:: ../../code/uvtee/main.c
:language: c
:linenos:
:lines: 61-80
:emphasize-lines: 4,5,15
@ -218,6 +223,7 @@ these buffers.
.. rubric:: uvtee/main.c - reading buffers
.. literalinclude:: ../../code/uvtee/main.c
:language: c
:linenos:
:lines: 19-22,44-60
@ -242,6 +248,7 @@ point there is nothing to be read. Most applications will just ignore this.
.. rubric:: uvtee/main.c - Write to pipe
.. literalinclude:: ../../code/uvtee/main.c
:language: c
:linenos:
:lines: 9-13,23-42
@ -282,6 +289,7 @@ The file change notification is started using ``uv_fs_event_init()``:
.. rubric:: onchange/main.c - The setup
.. literalinclude:: ../../code/onchange/main.c
:language: c
:linenos:
:lines: 26-
:emphasize-lines: 15
@ -320,6 +328,7 @@ In our example we simply print the arguments and run the command using
.. rubric:: onchange/main.c - file change notification callback
.. literalinclude:: ../../code/onchange/main.c
:language: c
:linenos:
:lines: 9-24

View File

@ -72,4 +72,4 @@ There is no need to ``make install``. To build the examples run ``make`` in the
.. _node.js: https://www.nodejs.org
.. _libev was removed: https://github.com/joyent/libuv/issues/485
.. _Rust: https://www.rust-lang.org
.. _variety: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv
.. _variety: https://github.com/libuv/libuv/blob/v1.x/LINKS.md

View File

@ -38,6 +38,7 @@ Here is a simple echo server
.. rubric:: tcp-echo-server/main.c - The listen socket
.. literalinclude:: ../../code/tcp-echo-server/main.c
:language: c
:linenos:
:lines: 68-
:emphasize-lines: 4-5,7-10
@ -60,6 +61,7 @@ In this case we also establish interest in reading from this stream.
.. rubric:: tcp-echo-server/main.c - Accepting the client
.. literalinclude:: ../../code/tcp-echo-server/main.c
:language: c
:linenos:
:lines: 51-66
:emphasize-lines: 9-10
@ -108,6 +110,7 @@ address from a `DHCP`_ server -- DHCP Discover.
.. rubric:: udp-dhcp/main.c - Setup and send UDP packets
.. literalinclude:: ../../code/udp-dhcp/main.c
:language: c
:linenos:
:lines: 7-11,104-
:emphasize-lines: 8,10-11,17-18,21
@ -143,6 +146,7 @@ the OS will discard the data that could not fit* (That's UDP for you!).
.. rubric:: udp-dhcp/main.c - Reading packets
.. literalinclude:: ../../code/udp-dhcp/main.c
:language: c
:linenos:
:lines: 17-40
:emphasize-lines: 1,23
@ -189,10 +193,11 @@ Querying DNS
libuv provides asynchronous DNS resolution. For this it provides its own
``getaddrinfo`` replacement [#]_. In the callback you can
perform normal socket operations on the retrieved addresses. Let's connect to
Freenode to see an example of DNS resolution.
Libera.chat to see an example of DNS resolution.
.. rubric:: dns/main.c
.. literalinclude:: ../../code/dns/main.c
:language: c
:linenos:
:lines: 61-
:emphasize-lines: 12
@ -209,6 +214,7 @@ call ``uv_freeaddrinfo`` in the callback.
.. rubric:: dns/main.c
.. literalinclude:: ../../code/dns/main.c
:language: c
:linenos:
:lines: 42-60
:emphasize-lines: 8,16
@ -227,6 +233,7 @@ useful to allow your service to bind to IP addresses when it starts.
.. rubric:: interfaces/main.c
.. literalinclude:: ../../code/interfaces/main.c
:language: c
:linenos:
:emphasize-lines: 9,17

View File

@ -27,6 +27,7 @@ exits. This is achieved using ``uv_spawn``.
.. rubric:: spawn/main.c
.. literalinclude:: ../../code/spawn/main.c
:language: c
:linenos:
:lines: 6-8,15-
:emphasize-lines: 11,13-17
@ -54,6 +55,7 @@ which caused the exit.
.. rubric:: spawn/main.c
.. literalinclude:: ../../code/spawn/main.c
:language: c
:linenos:
:lines: 9-12
:emphasize-lines: 3
@ -104,6 +106,7 @@ does not affect it.
.. rubric:: detach/main.c
.. literalinclude:: ../../code/detach/main.c
:language: c
:linenos:
:lines: 9-30
:emphasize-lines: 12,19
@ -140,6 +143,7 @@ stop watching. Here is a small example demonstrating the various possibilities:
.. rubric:: signal/main.c
.. literalinclude:: ../../code/signal/main.c
:language: c
:linenos:
:emphasize-lines: 17-18,27-28
@ -172,6 +176,7 @@ which is:
.. rubric:: proc-streams/test.c
.. literalinclude:: ../../code/proc-streams/test.c
:language: c
The actual program ``proc-streams`` runs this while sharing only ``stderr``.
The file descriptors of the child process are set using the ``stdio`` field in
@ -199,6 +204,7 @@ Then we set the ``fd`` to ``stderr``.
.. rubric:: proc-streams/main.c
.. literalinclude:: ../../code/proc-streams/main.c
:language: c
:linenos:
:lines: 15-17,27-
:emphasize-lines: 6,10,11,12
@ -217,12 +223,14 @@ A sample CGI script/executable is:
.. rubric:: cgi/tick.c
.. literalinclude:: ../../code/cgi/tick.c
:language: c
The CGI server combines the concepts from this chapter and :doc:`networking` so
that every client is sent ten ticks after which that connection is closed.
.. rubric:: cgi/main.c
.. literalinclude:: ../../code/cgi/main.c
:language: c
:linenos:
:lines: 49-63
:emphasize-lines: 10
@ -232,6 +240,7 @@ Here we simply accept the TCP connection and pass on the socket (*stream*) to
.. rubric:: cgi/main.c
.. literalinclude:: ../../code/cgi/main.c
:language: c
:linenos:
:lines: 16, 25-45
:emphasize-lines: 8-9,18,20
@ -291,6 +300,7 @@ messaging is no different from TCP, so we'll re-use the echo server example.
.. rubric:: pipe-echo-server/main.c
.. literalinclude:: ../../code/pipe-echo-server/main.c
:language: c
:linenos:
:lines: 70-
:emphasize-lines: 5,10,14
@ -330,6 +340,7 @@ it by the master.
.. rubric:: multi-echo-server/worker.c
.. literalinclude:: ../../code/multi-echo-server/worker.c
:language: c
:linenos:
:lines: 7-9,81-
:emphasize-lines: 6-8
@ -343,6 +354,7 @@ standard input of the worker, we connect the pipe to ``stdin`` using
.. rubric:: multi-echo-server/worker.c
.. literalinclude:: ../../code/multi-echo-server/worker.c
:language: c
:linenos:
:lines: 51-79
:emphasize-lines: 10,15,20
@ -361,6 +373,7 @@ allow load balancing.
.. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c
:language: c
:linenos:
:lines: 9-13
@ -369,6 +382,7 @@ master and the individual process.
.. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c
:language: c
:linenos:
:lines: 51,61-95
:emphasize-lines: 17,20-21
@ -387,6 +401,7 @@ worker in the round-robin.
.. rubric:: multi-echo-server/main.c
.. literalinclude:: ../../code/multi-echo-server/main.c
:language: c
:linenos:
:lines: 31-49
:emphasize-lines: 9,12-13

View File

@ -39,6 +39,7 @@ wait for it to close using ``uv_thread_join()``.
.. rubric:: thread-create/main.c
.. literalinclude:: ../../code/thread-create/main.c
:language: c
:linenos:
:lines: 26-36
:emphasize-lines: 3-7
@ -55,6 +56,7 @@ thread, scheduled pre-emptively by the operating system:
.. rubric:: thread-create/main.c
.. literalinclude:: ../../code/thread-create/main.c
:language: c
:linenos:
:lines: 6-14
:emphasize-lines: 2
@ -124,6 +126,7 @@ example.
.. rubric:: locks/main.c - simple rwlocks
.. literalinclude:: ../../code/locks/main.c
:language: c
:linenos:
:emphasize-lines: 13,16,27,31,42,55
@ -208,6 +211,7 @@ event loop from performing other activities.
.. rubric:: queue-work/main.c - lazy fibonacci
.. literalinclude:: ../../code/queue-work/main.c
:language: c
:linenos:
:lines: 17-29
@ -221,6 +225,7 @@ The trigger is ``uv_queue_work``:
.. rubric:: queue-work/main.c
.. literalinclude:: ../../code/queue-work/main.c
:language: c
:linenos:
:lines: 31-44
:emphasize-lines: 10
@ -248,6 +253,7 @@ up a signal handler for termination.
.. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c
:language: c
:linenos:
:lines: 43-
@ -256,6 +262,7 @@ When the user triggers the signal by pressing ``Ctrl+C`` we send
.. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c
:language: c
:linenos:
:lines: 33-41
:emphasize-lines: 6
@ -265,6 +272,7 @@ with ``status`` set to ``UV_ECANCELED``.
.. rubric:: queue-cancel/main.c
.. literalinclude:: ../../code/queue-cancel/main.c
:language: c
:linenos:
:lines: 28-31
:emphasize-lines: 2
@ -292,6 +300,7 @@ informing the user of the status of running downloads.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
:language: c
:linenos:
:lines: 7-8,35-
:emphasize-lines: 2,11
@ -317,6 +326,7 @@ with the async watcher whenever it receives a message.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
:language: c
:linenos:
:lines: 10-24
:emphasize-lines: 7-8
@ -327,6 +337,7 @@ non-blocking and will return immediately.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
:language: c
:linenos:
:lines: 31-34
@ -336,6 +347,7 @@ Finally it is important to remember to clean up the watcher.
.. rubric:: progress/main.c
.. literalinclude:: ../../code/progress/main.c
:language: c
:linenos:
:lines: 26-29
:emphasize-lines: 3

View File

@ -87,6 +87,7 @@ JS object and can be ref/unrefed.
.. rubric:: ref-timer/main.c
.. literalinclude:: ../../code/ref-timer/main.c
:language: c
:linenos:
:lines: 5-8, 17-
:emphasize-lines: 9
@ -111,6 +112,7 @@ idle watcher to keep the UI operational.
.. rubric:: idle-compute/main.c
.. literalinclude:: ../../code/idle-compute/main.c
:language: c
:linenos:
:lines: 5-9, 34-
:emphasize-lines: 13
@ -123,6 +125,7 @@ keep calling the idle callback again.
.. rubric:: idle-compute/main.c
.. literalinclude:: ../../code/idle-compute/main.c
:language: c
:linenos:
:lines: 10-19
@ -215,6 +218,7 @@ progress with the download whenever libuv notifies of I/O readiness.
.. rubric:: uvwget/main.c - The setup
.. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos:
:lines: 1-9,140-
:emphasize-lines: 7,21,24-25
@ -235,6 +239,7 @@ So we add each argument as an URL
.. rubric:: uvwget/main.c - Adding urls
.. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos:
:lines: 39-56
:emphasize-lines: 13-14
@ -251,6 +256,7 @@ on sockets whenever ``handle_socket`` is called.
.. rubric:: uvwget/main.c - Setting up polling
.. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos:
:lines: 102-140
:emphasize-lines: 9,11,15,21,24
@ -271,6 +277,7 @@ mask with the new value. ``curl_perform`` is the crux of this program.
.. rubric:: uvwget/main.c - Driving libcurl.
.. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos:
:lines: 81-95
:emphasize-lines: 2,6-7,12
@ -288,6 +295,7 @@ transfers are done.
.. rubric:: uvwget/main.c - Reading transfer status.
.. literalinclude:: ../../code/uvwget/main.c
:language: c
:linenos:
:lines: 58-79
:emphasize-lines: 6,9-10,13-14
@ -312,6 +320,7 @@ Let us first look at the interface provided to plugin authors.
.. rubric:: plugin/plugin.h
.. literalinclude:: ../../code/plugin/plugin.h
:language: c
:linenos:
You can similarly add more functions that plugin authors can use to do useful
@ -319,6 +328,7 @@ things in your application [#]_. A sample plugin using this API is:
.. rubric:: plugin/hello.c
.. literalinclude:: ../../code/plugin/hello.c
:language: c
:linenos:
Our interface defines that all plugins should have an ``initialize`` function
@ -340,6 +350,7 @@ This is done by using ``uv_dlopen`` to first load the shared library
.. rubric:: plugin/main.c
.. literalinclude:: ../../code/plugin/main.c
:language: c
:linenos:
:lines: 7-
:emphasize-lines: 15, 18, 24
@ -393,6 +404,7 @@ Here is a simple example which prints white text on a red background:
.. rubric:: tty/main.c
.. literalinclude:: ../../code/tty/main.c
:language: c
:linenos:
:emphasize-lines: 11-12,14,17,27
@ -403,6 +415,7 @@ escape codes.
.. rubric:: tty-gravity/main.c
.. literalinclude:: ../../code/tty-gravity/main.c
:language: c
:linenos:
:emphasize-lines: 19,25,38

View File

@ -17,7 +17,7 @@ was primarily developed for use by `Node.js`_, but it's also used by `Luvit`_,
.. _Luvit: https://luvit.io
.. _Julia: https://julialang.org
.. _pyuv: https://github.com/saghul/pyuv
.. _others: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv
.. _others: https://github.com/libuv/libuv/blob/v1.x/LINKS.md
Features

View File

@ -533,7 +533,7 @@ API
.. note::
This function currently only returns a non-zero value on Linux, based
on cgroups if it is present.
on cgroups if it is present, and on z/OS based on RLIMIT_MEMLIMIT.
.. versionadded:: 1.29.0

View File

@ -118,3 +118,21 @@ API
function is blocking.
.. versionadded:: 1.16.0
.. c:function:: int uv_pipe(uv_file fds[2], int read_flags, int write_flags)
Create a pair of connected pipe handles.
Data may be written to `fds[1]` and read from `fds[0]`.
The resulting handles can be passed to `uv_pipe_open`, used with `uv_spawn`,
or for any other purpose.
Valid values for `flags` are:
- UV_NONBLOCK_PIPE: 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.
Equivalent to :man:`pipe(2)` with the `O_CLOEXEC` flag set.
.. versionadded:: 1.41.0

View File

@ -86,36 +86,63 @@ API
.. c:function:: int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb)
Starts polling the file descriptor. `events` is a bitmask made up of
UV_READABLE, UV_WRITABLE, UV_PRIORITIZED and UV_DISCONNECT. 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_READABLE`, `UV_WRITABLE`, `UV_PRIORITIZED` and `UV_DISCONNECT`. 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.
The UV_PRIORITIZED event is used to watch for sysfs interrupts or TCP out-of-band
messages.
The `UV_PRIORITIZED` event is used to watch for sysfs interrupts or TCP
out-of-band messages.
The UV_DISCONNECT event is optional in the sense that it may not be
reported and the user is free to ignore it, but it can help optimize the shutdown
path because an extra read or write call might be avoided.
The `UV_DISCONNECT` event is optional in the sense that it may not be
reported and the user is free to ignore it, but it can help optimize the
shutdown path because an extra read or write call might be avoided.
If an error happens while polling, `status` will be < 0 and corresponds
with one of the UV_E* error codes (see :ref:`errors`). The user should
with one of the `UV_E*` error codes (see :ref:`errors`). The user should
not close the socket while the handle is active. If the user does that
anyway, the callback *may* be called reporting an error status, but this
is **not** guaranteed.
anyway, the callback *may* be called reporting an error status, but this is
**not** guaranteed.
.. note::
Calling :c:func:`uv_poll_start` on a handle that is already active is fine. Doing so
will update the events mask that is being watched for.
Calling :c:func:`uv_poll_start` on a handle that is already active is
fine. Doing so will update the events mask that is being watched for.
.. note::
Though UV_DISCONNECT can be set, it is unsupported on AIX and as such will not be set
on the `events` field in the callback.
Though `UV_DISCONNECT` can be set, it is unsupported on AIX and as such
will not be set on the `events` field in the callback.
.. versionchanged:: 1.9.0 Added the UV_DISCONNECT event.
.. versionchanged:: 1.14.0 Added the UV_PRIORITIZED event.
.. note::
If one of the events `UV_READABLE` or `UV_WRITABLE` are set, the
callback will be called again, as long as the given fd/socket remains
readable or writable accordingly. Particularly in each of the following
scenarios:
* The callback has been called because the socket became
readable/writable and the callback did not conduct a read/write on
this socket at all.
* The callback committed a read on the socket, and has not read all the
available data (when `UV_READABLE` is set).
* The callback committed a write on the socket, but it remained
writable afterwards (when `UV_WRITABLE` is set).
* The socket has already became readable/writable before calling
:c:func:`uv_poll_start` on a poll handle associated with this socket,
and since then the state of the socket did not changed.
In all of the above listed scenarios, the socket remains readable or
writable and hence the callback will be called again (depending on the
events set in the bitmask). This behaviour is known as level
triggering.
.. versionchanged:: 1.9.0 Added the `UV_DISCONNECT` event.
.. versionchanged:: 1.14.0 Added the `UV_PRIORITIZED` event.
.. c:function:: int uv_poll_stop(uv_poll_t* poll)
Stop polling the file descriptor, the callback will no longer be called.
.. note::
Calling :c:func:`uv_poll_stop` is effective immediately: any pending
callback is also canceled, even if the socket state change notification
was already pending.
.. seealso:: The :c:type:`uv_handle_t` API functions also apply.

View File

@ -119,12 +119,14 @@ Data types
* flags may be specified to create a duplex data stream.
*/
UV_READABLE_PIPE = 0x10,
UV_WRITABLE_PIPE = 0x20
UV_WRITABLE_PIPE = 0x20,
/*
* Open the child pipe handle in overlapped mode on Windows.
* On Unix it is silently ignored.
*/
UV_OVERLAPPED_PIPE = 0x40
* When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the
* handle in non-blocking mode in the child. This may cause loss of data,
* if the child is not designed to handle to encounter this mode,
* but can also be significantly more efficient.
*/
UV_NONBLOCK_PIPE = 0x40
} uv_stdio_flags;

View File

@ -139,6 +139,11 @@ API
be made several times until there is no more data to read or
:c:func:`uv_read_stop` is called.
.. versionchanged:: 1.38.0 :c:func:`uv_read_start()` now consistently
returns `UV_EALREADY` when called twice, and `UV_EINVAL` when the
stream is closing. With older libuv versions, it returns `UV_EALREADY`
on Windows but not UNIX, and `UV_EINVAL` on UNIX but not Windows.
.. c:function:: int uv_read_stop(uv_stream_t*)
Stop reading data from the stream. The :c:type:`uv_read_cb` callback will
@ -146,6 +151,11 @@ API
This function is idempotent and may be safely called on a stopped stream.
This function will always succeed; hence, checking its return value is
unnecessary. A non-zero return indicates that finishing releasing resources
may be pending on the next input event on that TTY on Windows, and does not
indicate failure.
.. c:function:: int uv_write(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb)
Write data to stream. Buffers are written in order. Example:
@ -183,8 +193,9 @@ API
initialized with `ipc` == 1.
.. 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.
`send_handle` must be a TCP, pipe and UDP handle on Unix, or a TCP
handle on Windows, which is a server or a connection (listening or
connected state). Bound sockets or pipes will be assumed to be servers.
.. c:function:: int uv_try_write(uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs)
@ -197,6 +208,16 @@ API
* < 0: negative error code (``UV_EAGAIN`` is returned if no data can be sent
immediately).
.. c:function:: int uv_try_write2(uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t* send_handle)
Same as :c:func:`uv_try_write` and extended write function for sending
handles over a pipe like c:func:`uv_write2`.
Try to send a handle is not supported on Windows,
where it returns ``UV_EAGAIN``.
.. versionadded:: 1.42.0
.. c:function:: int uv_is_readable(const uv_stream_t* handle)
Returns 1 if the stream is readable, 0 otherwise.

View File

@ -81,10 +81,9 @@ API
initialized ``struct sockaddr_in`` or ``struct sockaddr_in6``.
When the port is already taken, you can expect to see an ``UV_EADDRINUSE``
error from either :c:func:`uv_tcp_bind`, :c:func:`uv_listen` or
:c:func:`uv_tcp_connect`. That is, a successful call to this function does
not guarantee that the call to :c:func:`uv_listen` or :c:func:`uv_tcp_connect`
will succeed as well.
error from :c:func:`uv_listen` or :c:func:`uv_tcp_connect`. That is,
a successful call to this function does not guarantee that the call
to :c:func:`uv_listen` or :c:func:`uv_tcp_connect` will succeed as well.
`flags` can contain ``UV_TCP_IPV6ONLY``, in which case dual-stack support
is disabled and only IPv6 is used.
@ -128,3 +127,20 @@ API
:c:func:`uv_tcp_close_reset` calls is not allowed.
.. versionadded:: 1.32.0
.. c:function:: int uv_socketpair(int type, int protocol, uv_os_sock_t socket_vector[2], int flags0, int flags1)
Create a pair of connected sockets with the specified properties.
The resulting handles can be passed to `uv_tcp_open`, used with `uv_spawn`,
or for any other purpose.
Valid values for `flags0` and `flags1` are:
- UV_NONBLOCK_PIPE: 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.
Equivalent to :man:`socketpair(2)` with a domain of AF_UNIX.
.. versionadded:: 1.41.0

View File

@ -53,6 +53,14 @@ Data types
* in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL.
*/
UV_UDP_MMSG_FREE = 16,
/*
* 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 supressing some ICMP error messages
* and enables full ICMP error reporting for faster failover.
* This flag is no-op on platforms other than Linux.
*/
UV_UDP_LINUX_RECVERR = 32,
/*
* Indicates that recvmmsg should be used, if available.
*/
@ -73,7 +81,8 @@ Data types
* `nread`: Number of bytes that have been received.
0 if there is no more data to read. Note that 0 may also mean that an
empty datagram was received (in this case `addr` is not NULL). < 0 if
a transmission error was detected.
a transmission error was detected; if using :man:`recvmmsg(2)` no more
chunks will be received and the buffer can be freed safely.
* `buf`: :c:type:`uv_buf_t` with the received data.
* `addr`: ``struct sockaddr*`` containing the address of the sender.
Can be NULL. Valid for the duration of the callback only.
@ -84,10 +93,11 @@ Data types
on error.
When using :man:`recvmmsg(2)`, chunks will have the `UV_UDP_MMSG_CHUNK` flag set,
those must not be freed. There will be a final callback with `nread` set to 0,
`addr` set to NULL and the buffer pointing at the initially allocated data with
the `UV_UDP_MMSG_CHUNK` flag cleared and the `UV_UDP_MMSG_FREE` flag set.
The callee can now safely free the provided buffer.
those must not be freed. If no errors occur, there will be a final callback with
`nread` set to 0, `addr` set to NULL and the buffer pointing at the initially
allocated data with the `UV_UDP_MMSG_CHUNK` flag cleared and the `UV_UDP_MMSG_FREE`
flag set. If a UDP socket error occurs, `nread` will be < 0. In either scenario,
the callee can now safely free the provided buffer.
.. versionchanged:: 1.40.0 added the `UV_UDP_MMSG_FREE` flag.
@ -176,7 +186,8 @@ API
with the address and port to bind to.
:param flags: Indicate how the socket will be bound,
``UV_UDP_IPV6ONLY`` and ``UV_UDP_REUSEADDR`` are supported.
``UV_UDP_IPV6ONLY``, ``UV_UDP_REUSEADDR``, and ``UV_UDP_RECVERR``
are supported.
:returns: 0 on success, or an error code < 0 on failure.
@ -393,6 +404,11 @@ API
:returns: 0 on success, or an error code < 0 on failure.
.. note::
When using :man:`recvmmsg(2)`, the number of messages received at a time is limited
by the number of max size dgrams that will fit into the buffer allocated in `alloc_cb`, and
`suggested_size` in `alloc_cb` for udp_recv is always set to the size of 1 max size dgram.
.. versionchanged:: 1.35.0 added support for :man:`recvmmsg(2)` on supported platforms).
The use of this feature requires a buffer larger than
2 * 64KB to be passed to `alloc_cb`.