Currently, when the `FreeRDP_PreferIPv6OverIPv4` option is `TRUE` and
the `getaddrinfo` function returns IPv4 addresses before IPv6 addresses,
the code tries all IPv6 addresses, but it doesn't try any IPv4 address.
This happens because the `get_next_addrinfo` function skips to the first
IPv6 address, but never goes back to try IPv4 addresses that appeared
earlier in the list. Let's fix this by reordering the address list
first when the `PreferIPv6OverIPv4` option is `TRUE`.
Co-Authored-By: Claude <noreply@anthropic.com>
Related: https://github.com/FreeRDP/FreeRDP/issues/5335
The `freerdp_tcp_connect_timeout` function doesn't fail currently in the
case of connection failure (e.g. destination unreachable). It fails only
in the case of the `WSAECONNRESET` error. That seems to be regression from
the refactoring made by commit e6c23cb5. Let's use again the recommended
`getsockopt` function with the `SO_ERROR` argument to check for errors and
fail for all kinds of errors. The nice side-effect is that FreeRDP now
fails with "Failed to connect" instead of "Broken pipe" error.
Co-Authored-By: Claude <noreply@anthropic.com>
Related: https://github.com/FreeRDP/FreeRDP/issues/5335
FreeRDP still fails to connect when first DNS entry is unreachable. The
commit 4286a4c doesn't fix that unfortunately. It tries to create a socket
for all DNS entries until the socket is created, but it doesn't verify
that it is actually possible to connect to that socket. Let's call also
the `freerdp_tcp_connect_timeout` function for all the entries until success.
Co-Authored-By: Claude <noreply@anthropic.com>
Related: https://github.com/FreeRDP/FreeRDP/issues/5335