150150
151151 :returns: 0 on success, or an error code < 0 on failure.
152152
153+ .. c:function:: int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr)
154+
155+ Associate the UDP handle to a remote address and port, so every
156+ message sent by this handle is automatically sent to that destination.
157+ Calling this function with a `NULL` `addr` disconnects the handle.
158+ Trying to call `uv_udp_connect()` on an already connected handle will result
159+ in an `UV_EISCONN` error. Trying to disconnect a handle that is not
160+ connected will return an `UV_ENOTCONN` error.
161+
162+ :param handle: UDP handle. Should have been initialized with
163+ :c:func:`uv_udp_init`.
164+
165+ :param addr: `struct sockaddr_in` or `struct sockaddr_in6`
166+ with the address and port to associate to.
167+
168+ :returns: 0 on success, or an error code < 0 on failure.
169+
170+ .. versionadded:: 1.27.0
171+
172+ .. c:function:: int uv_udp_getpeername(const uv_udp_t* handle, struct sockaddr* name, int* namelen)
173+
174+ Get the remote IP and port of the UDP handle on connected UDP handles.
175+ On unconnected handles, it returns `UV_ENOTCONN`.
176+
177+ :param handle: UDP handle. Should have been initialized with
178+ :c:func:`uv_udp_init` and bound.
179+
180+ :param name: Pointer to the structure to be filled with the address data.
181+ In order to support IPv4 and IPv6 `struct sockaddr_storage` should be
182+ used.
183+
184+ :param namelen: On input it indicates the data of the `name` field. On
185+ output it indicates how much of it was filled.
186+
187+ :returns: 0 on success, or an error code < 0 on failure
188+
189+ .. versionadded:: 1.27.0
190+
153191.. c:function:: int uv_udp_getsockname(const uv_udp_t* handle, struct sockaddr* name, int* namelen)
154192
155193 Get the local IP and port of the UDP handle.
247285 (``0.0.0.0 `` or ``:: ``) it will be changed to point to ``localhost``.
248286 This is done to match the behavior of Linux systems.
249287
288+ For connected UDP handles, `addr` must be set to `NULL`, otherwise it will
289+ return `UV_EISCONN` error.
290+
291+ For connectionless UDP handles, `addr` cannot be `NULL`, otherwise it will
292+ return `UV_EDESTADDRREQ` error.
293+
250294 :param req: UDP request handle. Need not be initialized.
251295
252296 :param handle: UDP handle. Should have been initialized with
@@ -266,15 +310,25 @@ API
266310 .. versionchanged:: 1.19.0 added ``0.0.0.0`` and ``::`` to ``localhost``
267311 mapping
268312
313+ .. versionchanged:: 1.27.0 added support for connected sockets
314+
269315.. c:function:: int uv_udp_try_send(uv_udp_t* handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr* addr)
270316
271317 Same as :c:func:`uv_udp_send`, but won't queue a send request if it can't
272318 be completed immediately.
273319
320+ For connected UDP handles, `addr` must be set to `NULL`, otherwise it will
321+ return `UV_EISCONN` error.
322+
323+ For connectionless UDP handles, `addr` cannot be `NULL`, otherwise it will
324+ return `UV_EDESTADDRREQ` error.
325+
274326 :returns: >= 0: number of bytes sent (it matches the given buffer size).
275327 < 0: negative error code (``UV_EAGAIN `` is returned when the message
276328 can't be sent immediately).
277329
330+ .. versionchanged:: 1.27.0 added support for connected sockets
331+
278332.. c:function:: int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb)
279333
280334 Prepare for receiving data. If the socket has not previously been bound
0 commit comments