mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 12:28:21 +01:00
When zero-timeout, only try first address in connect.
This commit is contained in:
parent
be67f63f4e
commit
83880dbed7
13
doc/tcp.html
13
doc/tcp.html
@ -242,11 +242,14 @@ established.
|
|||||||
|
|
||||||
<p class=note>
|
<p class=note>
|
||||||
Note: Starting with LuaSocket 3.0, the host name resolution
|
Note: Starting with LuaSocket 3.0, the host name resolution
|
||||||
depends on whether the socket was created by <a
|
depends on whether the socket was created by
|
||||||
href=#socket.tcp><tt>socket.tcp</tt></a> or <a
|
<a href=#socket.tcp><tt>socket.tcp</tt></a>,
|
||||||
href=#socket.tcp6><tt>socket.tcp6</tt></a>. Addresses from
|
<a href=#socket.tcp4><tt>socket.tcp4</tt></a> or
|
||||||
the appropriate family are tried in succession until the
|
<a href=#socket.tcp6><tt>socket.tcp6</tt></a>. Addresses from
|
||||||
first success or until the last failure.
|
the appropriate family (or both) are tried in the order
|
||||||
|
returned by the resolver until the
|
||||||
|
first success or until the last failure. If the timeout was
|
||||||
|
set to zero, only the first address is tried.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
|
@ -423,8 +423,8 @@ const char *inet_tryconnect(p_socket ps, int *family, const char *address,
|
|||||||
/* try connecting to remote address */
|
/* try connecting to remote address */
|
||||||
err = socket_strerror(socket_connect(ps, (SA *) iterator->ai_addr,
|
err = socket_strerror(socket_connect(ps, (SA *) iterator->ai_addr,
|
||||||
(socklen_t) iterator->ai_addrlen, tm));
|
(socklen_t) iterator->ai_addrlen, tm));
|
||||||
/* if success, break out of loop */
|
/* if success or timeout is zero, break out of loop */
|
||||||
if (err == NULL) {
|
if (err == NULL || timeout_iszero(tm)) {
|
||||||
*family = current_family;
|
*family = current_family;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user