diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index 2157007046..62d207261e 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -990,7 +990,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thre #define SWITCH_SO_TCP_NODELAY 512 #define SWITCH_SO_TCP_KEEPIDLE 520 #define SWITCH_SO_TCP_KEEPINTVL 530 - +#define SWITCH_SO_IPV6_V6ONLY 16384 /* Don't accept IPv4 connections on an IPv6 listening socket. */ /** * @def SWITCH_INET diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index 93514c8c1d..d60db15112 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -2971,7 +2971,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime) #ifdef WIN32 /* Enable dual-stack listening on Windows (if the listening address is IPv6), it's default on Linux */ if (switch_sockaddr_get_family(sa) == AF_INET6) { - rv = switch_socket_opt_set(listen_list.sock, 16384, 0); + rv = switch_socket_opt_set(listen_list.sock, SWITCH_SO_IPV6_V6ONLY, 0); if (rv) goto sock_fail; } #endif diff --git a/src/mod/event_handlers/mod_rayo/xmpp_streams.c b/src/mod/event_handlers/mod_rayo/xmpp_streams.c index fcc3c76213..e8e9f6487d 100644 --- a/src/mod/event_handlers/mod_rayo/xmpp_streams.c +++ b/src/mod/event_handlers/mod_rayo/xmpp_streams.c @@ -1539,7 +1539,7 @@ static void *SWITCH_THREAD_FUNC xmpp_listener_thread(switch_thread_t *thread, vo #ifdef WIN32 /* Enable dual-stack listening on Windows (if the listening address is IPv6), it's default on Linux */ if (switch_sockaddr_get_family(sa) == AF_INET6) { - rv = switch_socket_opt_set(listener->socket, 16384, 0); + rv = switch_socket_opt_set(listener->socket, SWITCH_SO_IPV6_V6ONLY, 0); if (rv) goto sock_fail; } #endif diff --git a/src/switch_msrp.c b/src/switch_msrp.c index 5eba9e34ec..6a75945874 100644 --- a/src/switch_msrp.c +++ b/src/switch_msrp.c @@ -252,8 +252,11 @@ static switch_status_t msock_init(char *ip, switch_port_t port, switch_socket_t switch_sockaddr_t *sa; switch_status_t rv; - rv = switch_sockaddr_info_get(&sa, ip, SWITCH_INET, port, 0, pool); - if (rv) goto sock_fail; + rv = switch_sockaddr_info_get(&sa, ip, SWITCH_UNSPEC, port, 0, pool); + if (rv) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot get information about MSRP listen IP address %s\n", ip); + goto sock_fail; + } rv = switch_socket_create(sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, pool); if (rv) goto sock_fail; @@ -261,6 +264,14 @@ static switch_status_t msock_init(char *ip, switch_port_t port, switch_socket_t rv = switch_socket_opt_set(*sock, SWITCH_SO_REUSEADDR, 1); if (rv) goto sock_fail; +#ifdef WIN32 + /* Enable dual-stack listening on Windows */ + if (switch_sockaddr_get_family(sa) == AF_INET6) { + rv = switch_socket_opt_set(*sock, SWITCH_SO_IPV6_V6ONLY, 0); + if (rv) goto sock_fail; + } +#endif + rv = switch_socket_bind(*sock, sa); if (rv) goto sock_fail;