Package io.netty.channel.socket
Class DefaultDatagramChannelConfig
- java.lang.Object
-
- io.netty.channel.DefaultChannelConfig
-
- io.netty.channel.socket.DefaultDatagramChannelConfig
-
- All Implemented Interfaces:
ChannelConfig,DatagramChannelConfig
public class DefaultDatagramChannelConfig extends DefaultChannelConfig implements DatagramChannelConfig
The defaultDatagramChannelConfigimplementation.
-
-
Field Summary
-
Fields inherited from class io.netty.channel.DefaultChannelConfig
channel
-
-
Constructor Summary
Constructors Constructor Description DefaultDatagramChannelConfig(DatagramChannel channel, java.net.DatagramSocket javaSocket)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.net.InetAddressgetInterface()Gets the address of the network interface used for multicast packets.java.net.NetworkInterfacegetNetworkInterface()Gets theStandardSocketOptions.IP_MULTICAST_IFoption.<T> TgetOption(ChannelOption<T> option)Return the value of the givenChannelOptionjava.util.Map<ChannelOption<?>,java.lang.Object>getOptions()Return all setChannelOption's.intgetReceiveBufferSize()Gets theStandardSocketOptions.SO_RCVBUFoption.intgetSendBufferSize()Gets theStandardSocketOptions.SO_SNDBUFoption.intgetTimeToLive()Gets theStandardSocketOptions.IP_MULTICAST_TTLoption.intgetTrafficClass()Gets theStandardSocketOptions.IP_TOSoption.booleanisBroadcast()Gets theStandardSocketOptions.SO_BROADCASToption.booleanisLoopbackModeDisabled()Gets theStandardSocketOptions.IP_MULTICAST_LOOPoption.booleanisReuseAddress()Gets theStandardSocketOptions.SO_REUSEADDRoption.protected java.net.DatagramSocketjavaSocket()DatagramChannelConfigsetAllocator(ByteBufAllocator allocator)Set theByteBufAllocatorwhich is used for the channel to allocate buffers.DatagramChannelConfigsetAutoClose(boolean autoClose)Sets whether theChannelshould be closed automatically and immediately on write failure.DatagramChannelConfigsetAutoRead(boolean autoRead)Sets ifChannelHandlerContext.read()will be invoked automatically so that a user application doesn't need to call it at all.DatagramChannelConfigsetBroadcast(boolean broadcast)Sets theStandardSocketOptions.SO_BROADCASToption.DatagramChannelConfigsetConnectTimeoutMillis(int connectTimeoutMillis)Sets the connect timeout of the channel in milliseconds.DatagramChannelConfigsetInterface(java.net.InetAddress interfaceAddress)Sets the address of the network interface used for multicast packets.DatagramChannelConfigsetLoopbackModeDisabled(boolean loopbackModeDisabled)Sets theStandardSocketOptions.IP_MULTICAST_LOOPoption.DatagramChannelConfigsetMaxMessagesPerRead(int maxMessagesPerRead)Deprecated.DatagramChannelConfigsetMaxMessagesPerWrite(int maxMessagesPerWrite)Set the maximum number of message to write per eventloop run.DatagramChannelConfigsetMessageSizeEstimator(MessageSizeEstimator estimator)Set theMessageSizeEstimatorwhich is used for the channel to detect the size of a message.DatagramChannelConfigsetNetworkInterface(java.net.NetworkInterface networkInterface)Sets theStandardSocketOptions.IP_MULTICAST_IFoption.<T> booleansetOption(ChannelOption<T> option, T value)Sets a configuration property with the specified name and value.DatagramChannelConfigsetReceiveBufferSize(int receiveBufferSize)Sets theStandardSocketOptions.SO_RCVBUFoption.DatagramChannelConfigsetRecvByteBufAllocator(RecvByteBufAllocator allocator)Set theRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.DatagramChannelConfigsetReuseAddress(boolean reuseAddress)Gets theStandardSocketOptions.SO_REUSEADDRoption.DatagramChannelConfigsetSendBufferSize(int sendBufferSize)Sets theStandardSocketOptions.SO_SNDBUFoption.DatagramChannelConfigsetTimeToLive(int ttl)Sets theStandardSocketOptions.IP_MULTICAST_TTLoption.DatagramChannelConfigsetTrafficClass(int trafficClass)Sets theStandardSocketOptions.IP_TOSoption.DatagramChannelConfigsetWriteBufferHighWaterMark(int writeBufferHighWaterMark)Sets the high water mark of the write buffer.DatagramChannelConfigsetWriteBufferLowWaterMark(int writeBufferLowWaterMark)Sets the low water mark of the write buffer.DatagramChannelConfigsetWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)Set theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.DatagramChannelConfigsetWriteSpinCount(int writeSpinCount)Sets the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)returns a non-zero value.-
Methods inherited from class io.netty.channel.DefaultChannelConfig
autoReadCleared, getAllocator, getConnectTimeoutMillis, getMaxMessagesPerRead, getMaxMessagesPerWrite, getMessageSizeEstimator, getOptions, getRecvByteBufAllocator, getWriteBufferHighWaterMark, getWriteBufferLowWaterMark, getWriteBufferWaterMark, getWriteSpinCount, isAutoClose, isAutoRead, setOptions, validate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelConfig
getAllocator, getConnectTimeoutMillis, getMaxMessagesPerRead, getMessageSizeEstimator, getRecvByteBufAllocator, getWriteBufferHighWaterMark, getWriteBufferLowWaterMark, getWriteBufferWaterMark, getWriteSpinCount, isAutoClose, isAutoRead, setOptions
-
-
-
-
Constructor Detail
-
DefaultDatagramChannelConfig
public DefaultDatagramChannelConfig(DatagramChannel channel, java.net.DatagramSocket javaSocket)
Creates a new instance.
-
-
Method Detail
-
javaSocket
protected final java.net.DatagramSocket javaSocket()
-
getOptions
public java.util.Map<ChannelOption<?>,java.lang.Object> getOptions()
Description copied from interface:ChannelConfigReturn all setChannelOption's.- Specified by:
getOptionsin interfaceChannelConfig- Overrides:
getOptionsin classDefaultChannelConfig
-
getOption
public <T> T getOption(ChannelOption<T> option)
Description copied from interface:ChannelConfigReturn the value of the givenChannelOption- Specified by:
getOptionin interfaceChannelConfig- Overrides:
getOptionin classDefaultChannelConfig
-
setOption
public <T> boolean setOption(ChannelOption<T> option, T value)
Description copied from interface:ChannelConfigSets a configuration property with the specified name and value. To override this method properly, you must call the super class:public boolean setOption(ChannelOption<T> option, T value) { if (super.setOption(option, value)) { return true; } if (option.equals(additionalOption)) { .... return true; } return false; }- Specified by:
setOptionin interfaceChannelConfig- Overrides:
setOptionin classDefaultChannelConfig- Returns:
trueif and only if the property has been set
-
isBroadcast
public boolean isBroadcast()
Description copied from interface:DatagramChannelConfigGets theStandardSocketOptions.SO_BROADCASToption.- Specified by:
isBroadcastin interfaceDatagramChannelConfig
-
setBroadcast
public DatagramChannelConfig setBroadcast(boolean broadcast)
Description copied from interface:DatagramChannelConfigSets theStandardSocketOptions.SO_BROADCASToption.- Specified by:
setBroadcastin interfaceDatagramChannelConfig
-
getInterface
public java.net.InetAddress getInterface()
Description copied from interface:DatagramChannelConfigGets the address of the network interface used for multicast packets.- Specified by:
getInterfacein interfaceDatagramChannelConfig
-
setInterface
public DatagramChannelConfig setInterface(java.net.InetAddress interfaceAddress)
Description copied from interface:DatagramChannelConfigSets the address of the network interface used for multicast packets.- Specified by:
setInterfacein interfaceDatagramChannelConfig
-
isLoopbackModeDisabled
public boolean isLoopbackModeDisabled()
Description copied from interface:DatagramChannelConfigGets theStandardSocketOptions.IP_MULTICAST_LOOPoption.- Specified by:
isLoopbackModeDisabledin interfaceDatagramChannelConfig- Returns:
trueif and only if the loopback mode has been disabled
-
setLoopbackModeDisabled
public DatagramChannelConfig setLoopbackModeDisabled(boolean loopbackModeDisabled)
Description copied from interface:DatagramChannelConfigSets theStandardSocketOptions.IP_MULTICAST_LOOPoption.- Specified by:
setLoopbackModeDisabledin interfaceDatagramChannelConfig- Parameters:
loopbackModeDisabled-trueif and only if the loopback mode has been disabled
-
getNetworkInterface
public java.net.NetworkInterface getNetworkInterface()
Description copied from interface:DatagramChannelConfigGets theStandardSocketOptions.IP_MULTICAST_IFoption.- Specified by:
getNetworkInterfacein interfaceDatagramChannelConfig
-
setNetworkInterface
public DatagramChannelConfig setNetworkInterface(java.net.NetworkInterface networkInterface)
Description copied from interface:DatagramChannelConfigSets theStandardSocketOptions.IP_MULTICAST_IFoption.- Specified by:
setNetworkInterfacein interfaceDatagramChannelConfig
-
isReuseAddress
public boolean isReuseAddress()
Description copied from interface:DatagramChannelConfigGets theStandardSocketOptions.SO_REUSEADDRoption.- Specified by:
isReuseAddressin interfaceDatagramChannelConfig
-
setReuseAddress
public DatagramChannelConfig setReuseAddress(boolean reuseAddress)
Description copied from interface:DatagramChannelConfigGets theStandardSocketOptions.SO_REUSEADDRoption.- Specified by:
setReuseAddressin interfaceDatagramChannelConfig
-
getReceiveBufferSize
public int getReceiveBufferSize()
Description copied from interface:DatagramChannelConfigGets theStandardSocketOptions.SO_RCVBUFoption.- Specified by:
getReceiveBufferSizein interfaceDatagramChannelConfig
-
setReceiveBufferSize
public DatagramChannelConfig setReceiveBufferSize(int receiveBufferSize)
Description copied from interface:DatagramChannelConfigSets theStandardSocketOptions.SO_RCVBUFoption.- Specified by:
setReceiveBufferSizein interfaceDatagramChannelConfig
-
getSendBufferSize
public int getSendBufferSize()
Description copied from interface:DatagramChannelConfigGets theStandardSocketOptions.SO_SNDBUFoption.- Specified by:
getSendBufferSizein interfaceDatagramChannelConfig
-
setSendBufferSize
public DatagramChannelConfig setSendBufferSize(int sendBufferSize)
Description copied from interface:DatagramChannelConfigSets theStandardSocketOptions.SO_SNDBUFoption.- Specified by:
setSendBufferSizein interfaceDatagramChannelConfig
-
getTimeToLive
public int getTimeToLive()
Description copied from interface:DatagramChannelConfigGets theStandardSocketOptions.IP_MULTICAST_TTLoption.- Specified by:
getTimeToLivein interfaceDatagramChannelConfig
-
setTimeToLive
public DatagramChannelConfig setTimeToLive(int ttl)
Description copied from interface:DatagramChannelConfigSets theStandardSocketOptions.IP_MULTICAST_TTLoption.- Specified by:
setTimeToLivein interfaceDatagramChannelConfig
-
getTrafficClass
public int getTrafficClass()
Description copied from interface:DatagramChannelConfigGets theStandardSocketOptions.IP_TOSoption.- Specified by:
getTrafficClassin interfaceDatagramChannelConfig
-
setTrafficClass
public DatagramChannelConfig setTrafficClass(int trafficClass)
Description copied from interface:DatagramChannelConfigSets theStandardSocketOptions.IP_TOSoption.- Specified by:
setTrafficClassin interfaceDatagramChannelConfig
-
setWriteSpinCount
public DatagramChannelConfig setWriteSpinCount(int writeSpinCount)
Description copied from interface:ChannelConfigSets the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)returns a non-zero value. It is similar to what a spin lock is used for in concurrency programming. It improves memory utilization and write throughput depending on the platform that JVM runs on. The default value is16.- Specified by:
setWriteSpinCountin interfaceChannelConfig- Specified by:
setWriteSpinCountin interfaceDatagramChannelConfig- Overrides:
setWriteSpinCountin classDefaultChannelConfig
-
setConnectTimeoutMillis
public DatagramChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)
Description copied from interface:ChannelConfigSets the connect timeout of the channel in milliseconds. If theChanneldoes not support connect operation, this property is not used at all, and therefore will be ignored.- Specified by:
setConnectTimeoutMillisin interfaceChannelConfig- Specified by:
setConnectTimeoutMillisin interfaceDatagramChannelConfig- Overrides:
setConnectTimeoutMillisin classDefaultChannelConfig- Parameters:
connectTimeoutMillis- the connect timeout in milliseconds.0to disable.
-
setMaxMessagesPerRead
@Deprecated public DatagramChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead)
Deprecated.Description copied from class:DefaultChannelConfig- Specified by:
setMaxMessagesPerReadin interfaceChannelConfig- Specified by:
setMaxMessagesPerReadin interfaceDatagramChannelConfig- Overrides:
setMaxMessagesPerReadin classDefaultChannelConfig
-
setAllocator
public DatagramChannelConfig setAllocator(ByteBufAllocator allocator)
Description copied from interface:ChannelConfigSet theByteBufAllocatorwhich is used for the channel to allocate buffers.- Specified by:
setAllocatorin interfaceChannelConfig- Specified by:
setAllocatorin interfaceDatagramChannelConfig- Overrides:
setAllocatorin classDefaultChannelConfig
-
setRecvByteBufAllocator
public DatagramChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator)
Description copied from interface:ChannelConfigSet theRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.- Specified by:
setRecvByteBufAllocatorin interfaceChannelConfig- Specified by:
setRecvByteBufAllocatorin interfaceDatagramChannelConfig- Overrides:
setRecvByteBufAllocatorin classDefaultChannelConfig
-
setAutoRead
public DatagramChannelConfig setAutoRead(boolean autoRead)
Description copied from interface:ChannelConfigSets ifChannelHandlerContext.read()will be invoked automatically so that a user application doesn't need to call it at all. The default value istrue.- Specified by:
setAutoReadin interfaceChannelConfig- Specified by:
setAutoReadin interfaceDatagramChannelConfig- Overrides:
setAutoReadin classDefaultChannelConfig
-
setAutoClose
public DatagramChannelConfig setAutoClose(boolean autoClose)
Description copied from interface:ChannelConfigSets whether theChannelshould be closed automatically and immediately on write failure. The default istrue.- Specified by:
setAutoClosein interfaceChannelConfig- Specified by:
setAutoClosein interfaceDatagramChannelConfig- Overrides:
setAutoClosein classDefaultChannelConfig
-
setWriteBufferHighWaterMark
public DatagramChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark)
Description copied from interface:ChannelConfigSets the high water mark of the write buffer. If the number of bytes queued in the write buffer exceeds this value,
Channel.isWritable()will start to returnfalse.- Specified by:
setWriteBufferHighWaterMarkin interfaceChannelConfig- Overrides:
setWriteBufferHighWaterMarkin classDefaultChannelConfig
-
setWriteBufferLowWaterMark
public DatagramChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark)
Description copied from interface:ChannelConfigSets the low water mark of the write buffer. Once the number of bytes queued in the write buffer exceeded the high water mark and then dropped down below this value,
Channel.isWritable()will start to returntrueagain.- Specified by:
setWriteBufferLowWaterMarkin interfaceChannelConfig- Overrides:
setWriteBufferLowWaterMarkin classDefaultChannelConfig
-
setWriteBufferWaterMark
public DatagramChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
Description copied from interface:ChannelConfigSet theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.- Specified by:
setWriteBufferWaterMarkin interfaceChannelConfig- Specified by:
setWriteBufferWaterMarkin interfaceDatagramChannelConfig- Overrides:
setWriteBufferWaterMarkin classDefaultChannelConfig
-
setMessageSizeEstimator
public DatagramChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator)
Description copied from interface:ChannelConfigSet theMessageSizeEstimatorwhich is used for the channel to detect the size of a message.- Specified by:
setMessageSizeEstimatorin interfaceChannelConfig- Specified by:
setMessageSizeEstimatorin interfaceDatagramChannelConfig- Overrides:
setMessageSizeEstimatorin classDefaultChannelConfig
-
setMaxMessagesPerWrite
public DatagramChannelConfig setMaxMessagesPerWrite(int maxMessagesPerWrite)
Description copied from class:DefaultChannelConfigSet the maximum number of message to write per eventloop run. Once this limit is reached we will continue to process other events before trying to write the remaining messages.- Overrides:
setMaxMessagesPerWritein classDefaultChannelConfig
-
-