546 * interface was specified.
547 * When ICMPv6 support improves in windows, we may change this.
548 */
549 if (!(IS_NULL(ifArray))) {
550 /*
551 * If we can create a RAW socket, then when can use the ICMP ECHO_REQUEST
552 * otherwise we'll try a tcp socket to the Echo port (7).
553 * Note that this is empiric, and not connecting could mean it's blocked
554 * or the echo servioe has been disabled.
555 */
556 fd = NET_Socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
557
558 if (fd != -1) { /* Good to go, let's do a ping */
559 return ping6(env, fd, &him6, timeout, netif, ttl);
560 }
561 }
562 #endif
563
564 /* No good, let's fall back on TCP */
565 fd = NET_Socket(AF_INET6, SOCK_STREAM, 0);
566 if (fd == JVM_IO_ERR) {
567 /* note: if you run out of fds, you may not be able to load
568 * the exception class, and get a NoClassDefFoundError
569 * instead.
570 */
571 NET_ThrowNew(env, errno, "Can't create socket");
572 return JNI_FALSE;
573 }
574
575 /**
576 * A TTL was specified, let's set the socket option.
577 */
578 if (ttl > 0) {
579 setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (const char *)&ttl, sizeof(ttl));
580 }
581
582 /**
583 * A network interface was specified, let's bind to it.
584 */
585 if (netif != NULL) {
586 if (NET_Bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in6)) < 0) {
|
546 * interface was specified.
547 * When ICMPv6 support improves in windows, we may change this.
548 */
549 if (!(IS_NULL(ifArray))) {
550 /*
551 * If we can create a RAW socket, then when can use the ICMP ECHO_REQUEST
552 * otherwise we'll try a tcp socket to the Echo port (7).
553 * Note that this is empiric, and not connecting could mean it's blocked
554 * or the echo servioe has been disabled.
555 */
556 fd = NET_Socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
557
558 if (fd != -1) { /* Good to go, let's do a ping */
559 return ping6(env, fd, &him6, timeout, netif, ttl);
560 }
561 }
562 #endif
563
564 /* No good, let's fall back on TCP */
565 fd = NET_Socket(AF_INET6, SOCK_STREAM, 0);
566 if (fd == SOCKET_ERROR) {
567 /* note: if you run out of fds, you may not be able to load
568 * the exception class, and get a NoClassDefFoundError
569 * instead.
570 */
571 NET_ThrowNew(env, errno, "Can't create socket");
572 return JNI_FALSE;
573 }
574
575 /**
576 * A TTL was specified, let's set the socket option.
577 */
578 if (ttl > 0) {
579 setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (const char *)&ttl, sizeof(ttl));
580 }
581
582 /**
583 * A network interface was specified, let's bind to it.
584 */
585 if (netif != NULL) {
586 if (NET_Bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in6)) < 0) {
|