Example #1
0
  private static DatagramChannel newSocket(
      SelectorProvider provider, InternetProtocolFamily ipFamily) {
    if (ipFamily == null) {
      return newSocket(provider);
    }

    checkJavaVersion();

    try {
      return provider.openDatagramChannel(ProtocolFamilyConverter.convert(ipFamily));
    } catch (IOException e) {
      throw new ChannelException("Failed to open a socket.", e);
    }
  }
  private static DatagramChannel newSocket(InternetProtocolFamily ipFamily) {
    if (ipFamily == null) {
      return newSocket();
    }

    if (PlatformDependent.javaVersion() < 7) {
      throw new UnsupportedOperationException();
    }

    try {
      return DatagramChannel.open(ProtocolFamilyConverter.convert(ipFamily));
    } catch (IOException e) {
      throw new ChannelException("Failed to open a socket.", e);
    }
  }