#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
#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
#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
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;
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;