Skip to content

Commit

Permalink
common: If IPv6 not supported, fall back to IPv4
Browse files Browse the repository at this point in the history
The system to run xrdp does not necessarily support IPv6 even though
it is compiled with IPv6.

Fixes #432.
  • Loading branch information
metalefty committed Nov 22, 2016
1 parent a59645d commit 849a807
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions common/os_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,27 @@ g_tcp_socket(void)

#if defined(XRDP_ENABLE_IPV6)
rv = (int)socket(AF_INET6, SOCK_STREAM, 0);
if (rv < 0)
{
log_message(LOG_LEVEL_ERROR, "g_tcp_socket: %s", g_get_strerror());

switch (errno)
{
case EAFNOSUPPORT: /* if IPv6 not supported, retry IPv4 */
log_message(LOG_LEVEL_INFO, "IPv6 not supported, falling back to IPv4");
rv = (int)socket(AF_INET, SOCK_STREAM, 0);
break;

default:
return -1;
}
}
#else
rv = (int)socket(AF_INET, SOCK_STREAM, 0);
#endif
if (rv < 0)
{
log_message(LOG_LEVEL_ERROR, "g_tcp_socket: %s", g_get_strerror());
return -1;
}
#if defined(XRDP_ENABLE_IPV6)
Expand Down

0 comments on commit 849a807

Please sign in to comment.