<feed xmlns='http://www.w3.org/2005/Atom'>
<title>libubox/usock.c, branch master</title>
<subtitle>C utility functions for OpenWrt</subtitle>
<id>https://git-03.infra.openwrt.org/project/libubox/atom?h=master</id>
<link rel='self' href='https://git-03.infra.openwrt.org/project/libubox/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/'/>
<updated>2026-02-13T09:02:57Z</updated>
<entry>
<title>usock: implement RFC 8305 Happy Eyeballs for usock_inet_timeout()</title>
<updated>2026-02-13T09:02:57Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2026-02-13T08:55:11Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=1aa36ee774c8db4d7a396903e0d2e1fb79ee8bf1'/>
<id>urn:sha1:1aa36ee774c8db4d7a396903e0d2e1fb79ee8bf1</id>
<content type='text'>
Replace the two-slot (one v6 + one v4) connection attempt logic with
a multi-address interleaved approach per RFC 8305:

- Collect all resolved addresses and interleave them by family (v6
  first, then alternating v4/v6) using up to 8 candidates
- Stagger connection attempts with 250ms delay between each
- On connection error (SO_ERROR), immediately remove the failed
  socket and continue with remaining candidates
- First successful connection wins; all other sockets are closed

This handles hosts with multiple addresses per family, which the
previous code discarded.

Fixes: https://github.com/openwrt/uclient/issues/8
Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>usock: fix timeout handling in usock_inet_timeout()</title>
<updated>2026-02-13T09:02:45Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2026-02-13T08:52:09Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=1a73ded9f738d403784aa448910cf5c9f9b05e18'/>
<id>urn:sha1:1a73ded9f738d403784aa448910cf5c9f9b05e18</id>
<content type='text'>
Replace relative timeout arithmetic with an absolute CLOCK_MONOTONIC
deadline computed once at function entry. This avoids the case where
the IPv6 head-start delay subtraction produces a negative timeout for
the subsequent combined poll, causing it to return immediately.

Also give IPv6 a head start of min(300ms, remaining_timeout) instead
of skipping the head start entirely when the total timeout is &lt;= 300ms.

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>usock: check SO_ERROR after poll in usock_inet_timeout()</title>
<updated>2026-02-13T09:02:45Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2026-02-13T08:50:58Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=0efa2cd3b74ca295362341f7b21f0449066141f5'/>
<id>urn:sha1:0efa2cd3b74ca295362341f7b21f0449066141f5</id>
<content type='text'>
After poll() returns with POLLOUT on a non-blocking connect, the
connection may have failed (ECONNREFUSED, ENETUNREACH, etc.). Check
the socket error via getsockopt(SO_ERROR) before accepting the
connection as successful.

Without this, a fast-failing IPv6 connection would be returned to
the caller instead of falling back to IPv4.

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>usock: fix poll return code check</title>
<updated>2023-03-08T08:38:55Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2023-03-08T08:38:53Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=ef5e8e38bd38f26e2da2f6f0a2d720468c935280'/>
<id>urn:sha1:ef5e8e38bd38f26e2da2f6f0a2d720468c935280</id>
<content type='text'>
errno needs to be compared against EINTR/EAGAIN instead of the return code,
and only if the return code is &lt; 0.

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>usock: implement usock_inet_timeout() with RFC6555 support</title>
<updated>2016-01-28T11:07:25Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2016-01-28T10:56:46Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=0c2fbbca80a242280e5bb8b079184479c9abfa6f'/>
<id>urn:sha1:0c2fbbca80a242280e5bb8b079184479c9abfa6f</id>
<content type='text'>
Signed-off-by: Felix Fietkau &lt;nbd@openwrt.org&gt;
</content>
</entry>
<entry>
<title>usock: add usock_inet, which returns the remote address</title>
<updated>2016-01-15T20:04:16Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2016-01-15T20:04:16Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=f8b32f7620efdb73055f7fd6af4c796a770050e2'/>
<id>urn:sha1:f8b32f7620efdb73055f7fd6af4c796a770050e2</id>
<content type='text'>
Signed-off-by: Felix Fietkau &lt;nbd@openwrt.org&gt;
</content>
</entry>
<entry>
<title>usock: set socket flags right after creating it</title>
<updated>2015-01-15T12:10:58Z</updated>
<author>
<name>Rafał Miłecki</name>
</author>
<published>2015-01-15T11:42:52Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=f1c794b29e2dac52ec25869bf8c37b3e230fb2a2'/>
<id>urn:sha1:f1c794b29e2dac52ec25869bf8c37b3e230fb2a2</id>
<content type='text'>
Otherwise some flags like USOCK_NONBLOCK wouldn't work as expected
(O_NONBLOCK affects connect behavior).

Signed-off-by: RafaÅ‚ MiÅ‚ecki &lt;zajec5@gmail.com&gt;
</content>
</entry>
<entry>
<title>usock: add helper waiting for socket to be ready</title>
<updated>2015-01-15T12:10:49Z</updated>
<author>
<name>Rafał Miłecki</name>
</author>
<published>2015-01-15T11:59:18Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=ad9b5a387df86c3fa1bdf733b913f5bf4b751f21'/>
<id>urn:sha1:ad9b5a387df86c3fa1bdf733b913f5bf4b751f21</id>
<content type='text'>
Signed-off-by: RafaÅ‚ MiÅ‚ecki &lt;zajec5@gmail.com&gt;
</content>
</entry>
<entry>
<title>usock: add usock_port() for convenient use of numeric ports</title>
<updated>2014-09-23T10:01:00Z</updated>
<author>
<name>Jo-Philipp Wich</name>
</author>
<published>2014-09-22T16:15:58Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=fa73496098893e90330040b8f43f2773b42eed12'/>
<id>urn:sha1:fa73496098893e90330040b8f43f2773b42eed12</id>
<content type='text'>
Add a new helper function usock_port() which converts the given numeric port number
into a string using a private static buffer. This way a calling application can
conveniently use numeric port arguments without having to convert them before:

  int fd = usock(USOCK_UDP, "example.org", usock_port(80));

Signed-off-by: Jo-Philipp Wich &lt;jow@openwrt.org&gt;
</content>
</entry>
<entry>
<title>add license headers for usock</title>
<updated>2013-01-13T14:27:38Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2013-01-13T14:27:34Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=f5245f9887af7bf8f3468bf0ebca3c031da346ed'/>
<id>urn:sha1:f5245f9887af7bf8f3468bf0ebca3c031da346ed</id>
<content type='text'>
Signed-off-by: Felix Fietkau &lt;nbd@openwrt.org&gt;
</content>
</entry>
</feed>
