Java Code Examples for java.nio.channels.spi.SelectorProvider#openDatagramChannel()

The following examples show how to use java.nio.channels.spi.SelectorProvider#openDatagramChannel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NioDatagramChannel.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
private static DatagramChannel newSocket(SelectorProvider provider) {
    try {
        /**
         *  Use the {@link SelectorProvider} to open {@link SocketChannel} and so remove condition in
         *  {@link SelectorProvider#provider()} which is called by each DatagramChannel.open() otherwise.
         *
         *  See <a href="https://github.com/netty/netty/issues/2308">#2308</a>.
         */
        return provider.openDatagramChannel();
    } catch (IOException e) {
        throw new ChannelException("Failed to open a socket.", e);
    }
}
 
Example 2
Source File: NioDatagramChannel.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 3
Source File: UkcpClientUdpChannel.java    From kcp-netty with MIT License 5 votes vote down vote up
private static DatagramChannel newSocket(SelectorProvider provider) {
    try {
        /**
         *  Use the {@link SelectorProvider} to open {@link SocketChannel} and so remove condition in
         *  {@link SelectorProvider#provider()} which is called by each DatagramChannel.open() otherwise.
         *
         *  See <a href="https://github.com/netty/netty/issues/2308">#2308</a>.
         */
        return provider.openDatagramChannel();
    } catch (IOException e) {
        throw new ChannelException("Failed to open a socket.", e);
    }
}
 
Example 4
Source File: UkcpServerChannel.java    From kcp-netty with MIT License 5 votes vote down vote up
private static DatagramChannel newSocket(SelectorProvider provider) {
    try {
        /**
         *  Use the {@link SelectorProvider} to open {@link SocketChannel} and so remove condition in
         *  {@link SelectorProvider#provider()} which is called by each DatagramChannel.open() otherwise.
         *
         *  See <a href="https://github.com/netty/netty/issues/2308">#2308</a>.
         */
        return provider.openDatagramChannel();
    } catch (IOException e) {
        throw new ChannelException("Failed to open a socket.", e);
    }
}
 
Example 5
Source File: NioDatagramChannel.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
private static DatagramChannel newSocket(SelectorProvider provider) {
    try {
        /**
         *  Use the {@link SelectorProvider} to open {@link SocketChannel} and so remove condition in
         *  {@link SelectorProvider#provider()} which is called by each DatagramChannel.open() otherwise.
         *
         *  See <a href="See https://github.com/netty/netty/issues/2308">#2308</a>.
         */
        return provider.openDatagramChannel();
    } catch (IOException e) {
        throw new ChannelException("Failed to open a socket.", e);
    }
}
 
Example 6
Source File: NioDatagramChannel.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
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);
    }
}