Java Code Examples for io.netty.channel.ChannelOption#SO_BROADCAST

The following examples show how to use io.netty.channel.ChannelOption#SO_BROADCAST . 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: EpollDatagramChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public <T> T getOption(ChannelOption<T> option) {
    if (option == ChannelOption.SO_BROADCAST) {
        return (T) Boolean.valueOf(isBroadcast());
    }
    if (option == ChannelOption.SO_RCVBUF) {
        return (T) Integer.valueOf(getReceiveBufferSize());
    }
    if (option == ChannelOption.SO_SNDBUF) {
        return (T) Integer.valueOf(getSendBufferSize());
    }
    if (option == ChannelOption.SO_REUSEADDR) {
        return (T) Boolean.valueOf(isReuseAddress());
    }
    if (option == ChannelOption.IP_MULTICAST_LOOP_DISABLED) {
        return (T) Boolean.valueOf(isLoopbackModeDisabled());
    }
    if (option == ChannelOption.IP_MULTICAST_ADDR) {
        return (T) getInterface();
    }
    if (option == ChannelOption.IP_MULTICAST_IF) {
        return (T) getNetworkInterface();
    }
    if (option == ChannelOption.IP_MULTICAST_TTL) {
        return (T) Integer.valueOf(getTimeToLive());
    }
    if (option == ChannelOption.IP_TOS) {
        return (T) Integer.valueOf(getTrafficClass());
    }
    if (option == ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION) {
        return (T) Boolean.valueOf(activeOnOpen);
    }
    if (option == EpollChannelOption.SO_REUSEPORT) {
        return (T) Boolean.valueOf(isReusePort());
    }
    return super.getOption(option);
}
 
Example 2
Source File: EpollDatagramChannelConfig.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public <T> boolean setOption(ChannelOption<T> option, T value) {
    validate(option, value);

    if (option == ChannelOption.SO_BROADCAST) {
        setBroadcast((Boolean) value);
    } else if (option == ChannelOption.SO_RCVBUF) {
        setReceiveBufferSize((Integer) value);
    } else if (option == ChannelOption.SO_SNDBUF) {
        setSendBufferSize((Integer) value);
    } else if (option == ChannelOption.SO_REUSEADDR) {
        setReuseAddress((Boolean) value);
    } else if (option == ChannelOption.IP_MULTICAST_LOOP_DISABLED) {
        setLoopbackModeDisabled((Boolean) value);
    } else if (option == ChannelOption.IP_MULTICAST_ADDR) {
        setInterface((InetAddress) value);
    } else if (option == ChannelOption.IP_MULTICAST_IF) {
        setNetworkInterface((NetworkInterface) value);
    } else if (option == ChannelOption.IP_MULTICAST_TTL) {
        setTimeToLive((Integer) value);
    } else if (option == ChannelOption.IP_TOS) {
        setTrafficClass((Integer) value);
    } else if (option == ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION) {
        setActiveOnOpen((Boolean) value);
    } else if (option == EpollChannelOption.SO_REUSEPORT) {
        setReusePort((Boolean) value);
    } else {
        return super.setOption(option, value);
    }

    return true;
}
 
Example 3
Source File: EpollDatagramChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public <T> T getOption(ChannelOption<T> option) {
    if (option == ChannelOption.SO_BROADCAST) {
        return (T) Boolean.valueOf(isBroadcast());
    }
    if (option == ChannelOption.SO_RCVBUF) {
        return (T) Integer.valueOf(getReceiveBufferSize());
    }
    if (option == ChannelOption.SO_SNDBUF) {
        return (T) Integer.valueOf(getSendBufferSize());
    }
    if (option == ChannelOption.SO_REUSEADDR) {
        return (T) Boolean.valueOf(isReuseAddress());
    }
    if (option == ChannelOption.IP_MULTICAST_LOOP_DISABLED) {
        return (T) Boolean.valueOf(isLoopbackModeDisabled());
    }
    if (option == ChannelOption.IP_MULTICAST_ADDR) {
        return (T) getInterface();
    }
    if (option == ChannelOption.IP_MULTICAST_IF) {
        return (T) getNetworkInterface();
    }
    if (option == ChannelOption.IP_MULTICAST_TTL) {
        return (T) Integer.valueOf(getTimeToLive());
    }
    if (option == ChannelOption.IP_TOS) {
        return (T) Integer.valueOf(getTrafficClass());
    }
    if (option == ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION) {
        return (T) Boolean.valueOf(activeOnOpen);
    }
    if (option == EpollChannelOption.SO_REUSEPORT) {
        return (T) Boolean.valueOf(isReusePort());
    }
    return super.getOption(option);
}
 
Example 4
Source File: EpollDatagramChannelConfig.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public <T> boolean setOption(ChannelOption<T> option, T value) {
    validate(option, value);

    if (option == ChannelOption.SO_BROADCAST) {
        setBroadcast((Boolean) value);
    } else if (option == ChannelOption.SO_RCVBUF) {
        setReceiveBufferSize((Integer) value);
    } else if (option == ChannelOption.SO_SNDBUF) {
        setSendBufferSize((Integer) value);
    } else if (option == ChannelOption.SO_REUSEADDR) {
        setReuseAddress((Boolean) value);
    } else if (option == ChannelOption.IP_MULTICAST_LOOP_DISABLED) {
        setLoopbackModeDisabled((Boolean) value);
    } else if (option == ChannelOption.IP_MULTICAST_ADDR) {
        setInterface((InetAddress) value);
    } else if (option == ChannelOption.IP_MULTICAST_IF) {
        setNetworkInterface((NetworkInterface) value);
    } else if (option == ChannelOption.IP_MULTICAST_TTL) {
        setTimeToLive((Integer) value);
    } else if (option == ChannelOption.IP_TOS) {
        setTrafficClass((Integer) value);
    } else if (option == ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION) {
        setActiveOnOpen((Boolean) value);
    } else if (option == EpollChannelOption.SO_REUSEPORT) {
        setReusePort((Boolean) value);
    } else {
        return super.setOption(option, value);
    }

    return true;
}