Java Code Examples for java.nio.channels.DatagramChannel#isOpen()

The following examples show how to use java.nio.channels.DatagramChannel#isOpen() . 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
@Override
@SuppressWarnings("deprecation")
public boolean isActive() {
    DatagramChannel ch = javaChannel();
    return ch.isOpen() && (
            config.getOption(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION) && isRegistered()
            || ch.socket().isBound());
}
 
Example 2
Source File: GelfUdpAppender.java    From logback-gelf with GNU Lesser General Public License v2.1 5 votes vote down vote up
private DatagramChannel getChannel() throws IOException {
    DatagramChannel tmp = channel;

    if (!tmp.isOpen()) {
        synchronized (this) {
            tmp = channel;
            if (!tmp.isOpen() && !stopped) {
                tmp = DatagramChannel.open();
                channel = tmp;
            }
        }
    }

    return tmp;
}
 
Example 3
Source File: NioDatagramChannel.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public boolean isActive() {
    DatagramChannel ch = javaChannel();
    return ch.isOpen() && (
            config.getOption(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION) && isRegistered()
            || ch.socket().isBound());
}
 
Example 4
Source File: MultiSndDestination.java    From aeron with Apache License 2.0 5 votes vote down vote up
static int send(
    final DatagramChannel datagramChannel,
    final ByteBuffer buffer,
    final SendChannelEndpoint channelEndpoint,
    final int bytesToSend,
    final int position,
    final InetSocketAddress destination)
{
    int bytesSent = 0;
    try
    {
        if (datagramChannel.isOpen())
        {
            buffer.position(position);
            channelEndpoint.sendHook(buffer, destination);
            bytesSent = datagramChannel.send(buffer, destination);
        }
    }
    catch (final PortUnreachableException ignore)
    {
    }
    catch (final IOException ex)
    {
        sendError(bytesToSend, ex, destination);
    }

    return bytesSent;
}
 
Example 5
Source File: UkcpClientUdpChannel.java    From kcp-netty with MIT License 4 votes vote down vote up
@Override
public boolean isActive() {
    DatagramChannel ch = javaChannel();
    return ch.isOpen() && ch.socket().isBound();
}
 
Example 6
Source File: UkcpServerChannel.java    From kcp-netty with MIT License 4 votes vote down vote up
@Override
public boolean isActive() {
    DatagramChannel ch = javaChannel();
    return ch.isOpen() && ch.socket().isBound();
}