Package jnr.unixsocket
Class UnixDatagramChannel
- java.lang.Object
-
- java.nio.channels.spi.AbstractInterruptibleChannel
-
- java.nio.channels.SelectableChannel
-
- java.nio.channels.spi.AbstractSelectableChannel
-
- java.nio.channels.DatagramChannel
-
- jnr.unixsocket.impl.AbstractNativeDatagramChannel
-
- jnr.unixsocket.UnixDatagramChannel
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.ByteChannel
,java.nio.channels.Channel
,java.nio.channels.GatheringByteChannel
,java.nio.channels.InterruptibleChannel
,java.nio.channels.MulticastChannel
,java.nio.channels.NetworkChannel
,java.nio.channels.ReadableByteChannel
,java.nio.channels.ScatteringByteChannel
,java.nio.channels.WritableByteChannel
,jnr.enxio.channels.NativeSelectableChannel
public class UnixDatagramChannel extends AbstractNativeDatagramChannel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
UnixDatagramChannel.DefaultOptionsHolder
(package private) static class
UnixDatagramChannel.State
-
Field Summary
Fields Modifier and Type Field Description private BindHandler
bindHandler
private UnixSocketAddress
localAddress
private UnixSocketAddress
remoteAddress
private UnixDatagramChannel.State
state
private java.util.concurrent.locks.ReadWriteLock
stateLock
-
Constructor Summary
Constructors Modifier Constructor Description private
UnixDatagramChannel()
(package private)
UnixDatagramChannel(int fd)
(package private)
UnixDatagramChannel(int fd, UnixDatagramChannel.State initialState, boolean initialBoundState)
(package private)
UnixDatagramChannel(int fd, UnixSocketAddress remote)
(package private)
UnixDatagramChannel(jnr.constants.platform.ProtocolFamily domain, int protocol)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UnixDatagramChannel
bind(java.net.SocketAddress local)
java.nio.channels.DatagramChannel
connect(java.net.SocketAddress remote)
UnixDatagramChannel
connect(UnixSocketAddress remote)
UnixDatagramChannel
disconnect()
java.net.SocketAddress
getLocalAddress()
UnixSocketAddress
getLocalSocketAddress()
<T> T
getOption(java.net.SocketOption<T> name)
java.net.SocketAddress
getRemoteAddress()
UnixSocketAddress
getRemoteSocketAddress()
(package private) boolean
isBound()
boolean
isConnected()
java.nio.channels.MembershipKey
join(java.net.InetAddress group, java.net.NetworkInterface interf)
java.nio.channels.MembershipKey
join(java.net.InetAddress group, java.net.NetworkInterface interf, java.net.InetAddress source)
static UnixDatagramChannel
open()
static UnixDatagramChannel
open(jnr.constants.platform.ProtocolFamily domain, int protocol)
static UnixDatagramChannel[]
pair()
int
read(java.nio.ByteBuffer dst)
UnixSocketAddress
receive(java.nio.ByteBuffer src)
int
send(java.nio.ByteBuffer src, java.net.SocketAddress target)
<T> java.nio.channels.DatagramChannel
setOption(java.net.SocketOption<T> name, T value)
UnixDatagramSocket
socket()
java.util.Set<java.net.SocketOption<?>>
supportedOptions()
int
write(java.nio.ByteBuffer src)
long
write(java.nio.ByteBuffer[] srcs, int offset, int length)
-
Methods inherited from class jnr.unixsocket.impl.AbstractNativeDatagramChannel
getFD, implCloseSelectableChannel, implConfigureBlocking, read, setFD
-
Methods inherited from class java.nio.channels.spi.AbstractSelectableChannel
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, register
-
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
-
-
-
Field Detail
-
state
private UnixDatagramChannel.State state
-
remoteAddress
private UnixSocketAddress remoteAddress
-
localAddress
private UnixSocketAddress localAddress
-
stateLock
private final java.util.concurrent.locks.ReadWriteLock stateLock
-
bindHandler
private final BindHandler bindHandler
-
-
Constructor Detail
-
UnixDatagramChannel
private UnixDatagramChannel() throws java.io.IOException
- Throws:
java.io.IOException
-
UnixDatagramChannel
UnixDatagramChannel(jnr.constants.platform.ProtocolFamily domain, int protocol) throws java.io.IOException
- Throws:
java.io.IOException
-
UnixDatagramChannel
UnixDatagramChannel(int fd)
-
UnixDatagramChannel
UnixDatagramChannel(int fd, UnixDatagramChannel.State initialState, boolean initialBoundState)
-
UnixDatagramChannel
UnixDatagramChannel(int fd, UnixSocketAddress remote) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
open
public static final UnixDatagramChannel open() throws java.io.IOException
- Throws:
java.io.IOException
-
open
public static final UnixDatagramChannel open(jnr.constants.platform.ProtocolFamily domain, int protocol) throws java.io.IOException
- Throws:
java.io.IOException
-
pair
public static final UnixDatagramChannel[] pair() throws java.io.IOException
- Throws:
java.io.IOException
-
bind
public UnixDatagramChannel bind(java.net.SocketAddress local) throws java.io.IOException
- Specified by:
bind
in interfacejava.nio.channels.NetworkChannel
- Specified by:
bind
in classjava.nio.channels.DatagramChannel
- Throws:
java.io.IOException
-
connect
public UnixDatagramChannel connect(UnixSocketAddress remote)
-
disconnect
public UnixDatagramChannel disconnect() throws java.io.IOException
- Specified by:
disconnect
in classjava.nio.channels.DatagramChannel
- Throws:
java.io.IOException
-
isBound
boolean isBound()
-
isConnected
public boolean isConnected()
- Specified by:
isConnected
in classjava.nio.channels.DatagramChannel
-
getRemoteSocketAddress
public final UnixSocketAddress getRemoteSocketAddress()
-
getLocalSocketAddress
public final UnixSocketAddress getLocalSocketAddress()
-
receive
public UnixSocketAddress receive(java.nio.ByteBuffer src) throws java.io.IOException
- Specified by:
receive
in classjava.nio.channels.DatagramChannel
- Throws:
java.io.IOException
-
send
public int send(java.nio.ByteBuffer src, java.net.SocketAddress target) throws java.io.IOException
- Specified by:
send
in classjava.nio.channels.DatagramChannel
- Throws:
java.io.IOException
-
connect
public java.nio.channels.DatagramChannel connect(java.net.SocketAddress remote) throws java.io.IOException
- Specified by:
connect
in classjava.nio.channels.DatagramChannel
- Throws:
java.io.IOException
-
socket
public UnixDatagramSocket socket()
- Specified by:
socket
in classjava.nio.channels.DatagramChannel
-
write
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
- Specified by:
write
in interfacejava.nio.channels.GatheringByteChannel
- Overrides:
write
in classAbstractNativeDatagramChannel
- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
- Specified by:
read
in interfacejava.nio.channels.ReadableByteChannel
- Overrides:
read
in classAbstractNativeDatagramChannel
- Throws:
java.io.IOException
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException
- Specified by:
write
in interfacejava.nio.channels.WritableByteChannel
- Overrides:
write
in classAbstractNativeDatagramChannel
- Throws:
java.io.IOException
-
getRemoteAddress
public java.net.SocketAddress getRemoteAddress() throws java.io.IOException
- Specified by:
getRemoteAddress
in classjava.nio.channels.DatagramChannel
- Throws:
java.io.IOException
-
getLocalAddress
public java.net.SocketAddress getLocalAddress() throws java.io.IOException
- Specified by:
getLocalAddress
in interfacejava.nio.channels.NetworkChannel
- Specified by:
getLocalAddress
in classjava.nio.channels.DatagramChannel
- Throws:
java.io.IOException
-
supportedOptions
public final java.util.Set<java.net.SocketOption<?>> supportedOptions()
-
getOption
public <T> T getOption(java.net.SocketOption<T> name) throws java.io.IOException
- Throws:
java.io.IOException
-
setOption
public <T> java.nio.channels.DatagramChannel setOption(java.net.SocketOption<T> name, T value) throws java.io.IOException
- Specified by:
setOption
in interfacejava.nio.channels.NetworkChannel
- Specified by:
setOption
in classjava.nio.channels.DatagramChannel
- Throws:
java.io.IOException
-
join
public java.nio.channels.MembershipKey join(java.net.InetAddress group, java.net.NetworkInterface interf)
-
join
public java.nio.channels.MembershipKey join(java.net.InetAddress group, java.net.NetworkInterface interf, java.net.InetAddress source)
-
-