Module org.newsclub.net.unix
Package org.newsclub.net.unix
Class AFDatagramChannel<A extends AFSocketAddress>
java.lang.Object
java.nio.channels.spi.AbstractInterruptibleChannel
java.nio.channels.SelectableChannel
java.nio.channels.spi.AbstractSelectableChannel
java.nio.channels.DatagramChannel
org.newsclub.net.unix.AFDatagramChannel<A>
- All Implemented Interfaces:
Closeable,AutoCloseable,ByteChannel,Channel,GatheringByteChannel,InterruptibleChannel,MulticastChannel,NetworkChannel,ReadableByteChannel,ScatteringByteChannel,WritableByteChannel,AFSocketExtensions,AFSomeSocket,FileDescriptorAccess
- Direct Known Subclasses:
AFUNIXDatagramChannel
public abstract class AFDatagramChannel<A extends AFSocketAddress>
extends DatagramChannel
implements AFSomeSocket, AFSocketExtensions
A
DatagramChannel implementation that works with junixsocket.- Author:
- Christian Kohlschütter
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAFDatagramChannel(AFSelectorProvider<A> selectorProvider, AFDatagramSocket<A> socket) Creates a newAFDatagramChannelinstance. -
Method Summary
Modifier and TypeMethodDescriptionfinal AFDatagramChannel<A>bind(SocketAddress local) final AFDatagramChannel<A>connect(SocketAddress remote) final AFDatagramChannel<A>final voidensureAncillaryReceiveBufferSize(int minSize) Ensures a minimum ancillary receive buffer size.protected final AFDatagramSocket<A>Returns the correspondingSocket.final intReturns the size of the receive buffer for ancillary messages (in bytes).final FileDescriptorReturns the correspondingFileDescriptor.final @Nullable Afinal @Nullable AReturns the socket's local socket address, ornullif unavailable or if there was a problem retrieving it.final <T> TgetOption(SocketOption<T> name) final @Nullable Afinal @Nullable AReturns the socket's remote socket address, ornullif unavailable/not connected, or if there was a problem retrieving it.protected final voidprotected final voidimplConfigureBlocking(boolean block) final booleanisBound()Returns the binding state of the socket.final booleanfinal booleanChecks if thisDatagramSocket's bound filename should be removed uponAbstractInterruptibleChannel.close().final MembershipKeyjoin(InetAddress group, NetworkInterface interf) final MembershipKeyjoin(InetAddress group, NetworkInterface interf, InetAddress source) final intread(ByteBuffer dst) final longread(ByteBuffer[] dsts, int offset, int length) final Areceive(ByteBuffer dst) final intsend(ByteBuffer src, SocketAddress target) final voidsetAncillaryReceiveBufferSize(int size) Sets the size of the receive buffer for ancillary messages (in bytes).final voidsetDeleteOnClose(boolean b) Enables/disables deleting thisDatagramSocket's bound filename uponAbstractInterruptibleChannel.close().final <T> AFDatagramChannel<A>setOption(SocketOption<T> name, T value) final AFDatagramSocket<A>socket()final Set<SocketOption<?>>final intwrite(ByteBuffer src) final longwrite(ByteBuffer[] srcs, int offset, int length) Methods inherited from class java.nio.channels.spi.AbstractSelectableChannel
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, registerMethods inherited from class java.nio.channels.SelectableChannel
registerMethods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpenMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.nio.channels.MulticastChannel
close
-
Constructor Details
-
AFDatagramChannel
Creates a newAFDatagramChannelinstance.- Parameters:
selectorProvider- The correspondingSelectorProvider.socket- The correspondingSocket.
-
-
Method Details
-
getAFSocket
Returns the correspondingSocket.- Returns:
- The socket.
-
join
- Specified by:
joinin interfaceMulticastChannel- Throws:
IOException
-
join
public final MembershipKey join(InetAddress group, NetworkInterface interf, InetAddress source) throws IOException - Specified by:
joinin interfaceMulticastChannel- Throws:
IOException
-
bind
- Specified by:
bindin interfaceNetworkChannel- Specified by:
bindin classDatagramChannel- Throws:
IOException
-
socket
- Specified by:
socketin classDatagramChannel
-
isBound
public final boolean isBound()Returns the binding state of the socket.- Returns:
- true if the socket successfully bound to an address
-
isConnected
public final boolean isConnected()- Specified by:
isConnectedin classDatagramChannel
-
connect
- Specified by:
connectin classDatagramChannel- Throws:
IOException
-
disconnect
- Specified by:
disconnectin classDatagramChannel- Throws:
IOException
-
getRemoteAddress
- Specified by:
getRemoteAddressin classDatagramChannel- Throws:
IOException
-
getRemoteSocketAddress
Description copied from interface:AFSomeSocketReturns the socket's remote socket address, ornullif unavailable/not connected, or if there was a problem retrieving it.- Specified by:
getRemoteSocketAddressin interfaceAFSomeSocket- Returns:
- The remote socket address, or
null.
-
getLocalAddress
- Specified by:
getLocalAddressin interfaceNetworkChannel- Specified by:
getLocalAddressin classDatagramChannel- Throws:
IOException
-
getLocalSocketAddress
Description copied from interface:AFSomeSocketReturns the socket's local socket address, ornullif unavailable or if there was a problem retrieving it.- Specified by:
getLocalSocketAddressin interfaceAFSomeSocket- Returns:
- The local socket address, or
null.
-
receive
- Specified by:
receivein classDatagramChannel- Throws:
IOException
-
send
- Specified by:
sendin classDatagramChannel- Throws:
IOException
-
read
- Specified by:
readin interfaceReadableByteChannel- Specified by:
readin classDatagramChannel- Throws:
IOException
-
read
- Specified by:
readin interfaceScatteringByteChannel- Specified by:
readin classDatagramChannel- Throws:
IOException
-
write
- Specified by:
writein interfaceWritableByteChannel- Specified by:
writein classDatagramChannel- Throws:
IOException
-
write
- Specified by:
writein interfaceGatheringByteChannel- Specified by:
writein classDatagramChannel- Throws:
IOException
-
implCloseSelectableChannel
- Specified by:
implCloseSelectableChannelin classAbstractSelectableChannel- Throws:
IOException
-
implConfigureBlocking
- Specified by:
implConfigureBlockingin classAbstractSelectableChannel- Throws:
IOException
-
getAncillaryReceiveBufferSize
public final int getAncillaryReceiveBufferSize()Description copied from interface:AFSocketExtensionsReturns the size of the receive buffer for ancillary messages (in bytes).- Specified by:
getAncillaryReceiveBufferSizein interfaceAFSocketExtensions- Returns:
- The size.
-
setAncillaryReceiveBufferSize
public final void setAncillaryReceiveBufferSize(int size) Description copied from interface:AFSocketExtensionsSets the size of the receive buffer for ancillary messages (in bytes). To disable handling ancillary messages, set it to 0 (default).- Specified by:
setAncillaryReceiveBufferSizein interfaceAFSocketExtensions- Parameters:
size- The size.
-
ensureAncillaryReceiveBufferSize
public final void ensureAncillaryReceiveBufferSize(int minSize) Description copied from interface:AFSocketExtensionsEnsures a minimum ancillary receive buffer size.- Specified by:
ensureAncillaryReceiveBufferSizein interfaceAFSocketExtensions- Parameters:
minSize- The minimum size (in bytes).
-
setOption
- Specified by:
setOptionin interfaceNetworkChannel- Specified by:
setOptionin classDatagramChannel- Throws:
IOException
-
getOption
- Specified by:
getOptionin interfaceNetworkChannel- Throws:
IOException
-
supportedOptions
- Specified by:
supportedOptionsin interfaceNetworkChannel
-
getFileDescriptor
Description copied from interface:FileDescriptorAccessReturns the correspondingFileDescriptor.- Specified by:
getFileDescriptorin interfaceFileDescriptorAccess- Returns:
- The corresponding
FileDescriptor. - Throws:
IOException- on error.
-
isDeleteOnClose
public final boolean isDeleteOnClose()Checks if thisDatagramSocket's bound filename should be removed uponAbstractInterruptibleChannel.close(). Deletion is not guaranteed, especially when not supported (e.g., addresses in the abstract namespace).- Returns:
trueif an attempt is made to delete the socket file uponAbstractInterruptibleChannel.close().
-
setDeleteOnClose
public final void setDeleteOnClose(boolean b) Enables/disables deleting thisDatagramSocket's bound filename uponAbstractInterruptibleChannel.close(). Deletion is not guaranteed, especially when not supported (e.g., addresses in the abstract namespace).- Parameters:
b- Enabled iftrue.
-