public abstract class DatagramChannel extends java.nio.channels.spi.AbstractSelectableChannel implements ByteChannel, ScatteringByteChannel, GatheringByteChannel
| Modifier | Constructor and Description |
|---|---|
protected |
DatagramChannel(java.nio.channels.spi.SelectorProvider provider)
Initializes the channel.
|
| Modifier and Type | Method and Description |
|---|---|
abstract DatagramChannel |
connect(java.net.SocketAddress remote)
Connects this channel's socket.
|
abstract DatagramChannel |
disconnect()
Disonnects this channel's socket.
|
abstract boolean |
isConnected()
Tells whether or not this channel's socket is connected.
|
static DatagramChannel |
open()
Opens a datagram channel.
|
abstract int |
read(java.nio.ByteBuffer dst)
Reads data from this channel.
|
long |
read(java.nio.ByteBuffer[] dsts)
Reads data from this channel.
|
abstract long |
read(java.nio.ByteBuffer[] dsts,
int offset,
int length)
Reads data from this channel.
|
abstract java.net.SocketAddress |
receive(java.nio.ByteBuffer dst)
Receives a datagram via this channel.
|
abstract int |
send(java.nio.ByteBuffer src,
java.net.SocketAddress target)
Sends a datagram via this channel.
|
abstract java.net.DatagramSocket |
socket()
Retrieves the channel's socket.
|
int |
validOps()
Retrieves the valid operations for this channel.
|
abstract int |
write(java.nio.ByteBuffer src)
Writes data to this channel.
|
long |
write(java.nio.ByteBuffer[] srcs)
Writes data to this channel.
|
abstract long |
write(java.nio.ByteBuffer[] srcs,
int offset,
int length)
Writes data to this channel.
|
blockingLock, configureBlocking, implCloseChannel, implCloseSelectableChannel, implConfigureBlocking, isBlocking, isRegistered, keyFor, provider, registerregisterbegin, close, end, isOpenprotected DatagramChannel(java.nio.channels.spi.SelectorProvider provider)
public static DatagramChannel open() throws java.io.IOException
java.io.IOException - If an error occurspublic final long read(java.nio.ByteBuffer[] dsts) throws java.io.IOException
read in interface ScatteringByteChannelAsynchronousCloseException - If another thread closes this
channel while the write operation is in progressClosedByInterruptException - If another thread interrupts the
current thread while the write operation is in progress, thereby closing
the channel and setting the current thread's interrupt statusClosedChannelException - If this channel is closedjava.io.IOException - If an error occurspublic final long write(java.nio.ByteBuffer[] srcs) throws java.io.IOException
write in interface GatheringByteChanneljava.io.IOException - If an error occursNotYetConnectedException - The channel's socket is not connected.public abstract DatagramChannel connect(java.net.SocketAddress remote) throws java.io.IOException
AsynchronousCloseException - If another thread closes this channel
while the connect operation is in progress.ClosedByInterruptException - If another thread interrupts the
current thread while the read operation is in progress, thereby closing the
channel and setting the current thread's interrupt status.ClosedChannelException - If this channel is closed.java.io.IOException - If an error occurs.java.lang.SecurityException - If a security manager has been installed and
it does not permit datagrams to be sent to the given address.public abstract DatagramChannel disconnect() throws java.io.IOException
java.io.IOException - If an error occurspublic abstract boolean isConnected()
NotYetConnectedException - The channel's socket is not connected.public abstract int read(java.nio.ByteBuffer dst) throws java.io.IOException
read in interface ReadableByteChanneldst - the buffer to put the read data intoAsynchronousCloseException - If another thread closes this
channel while the read operation is in progressClosedByInterruptException - If another thread interrupts the
current thread while the read operation is in progress, thereby closing
the channel and setting the current thread's interrupt statusClosedChannelException - If this channel is closedjava.io.IOException - If an error occurspublic abstract long read(java.nio.ByteBuffer[] dsts, int offset, int length) throws java.io.IOException
read in interface ScatteringByteChanneljava.io.IOException - If an error occurs.NotYetConnectedException - The channel's socket is not connected.public abstract java.net.SocketAddress receive(java.nio.ByteBuffer dst) throws java.io.IOException
AsynchronousCloseException - If another thread closes this channel
while the connect operation is in progress.ClosedByInterruptException - If another thread interrupts the
current thread while the read operation is in progress, thereby closing the
channel and setting the current thread's interrupt status.ClosedChannelException - If this channel is closed.java.io.IOException - If an error occursjava.lang.SecurityException - If a security manager has been installed and
it does not permit datagrams to be sent to the given address.public abstract int send(java.nio.ByteBuffer src, java.net.SocketAddress target) throws java.io.IOException
AsynchronousCloseException - If another thread closes this channel
while the connect operation is in progress.ClosedByInterruptException - If another thread interrupts the
current thread while the read operation is in progress, thereby closing the
channel and setting the current thread's interrupt status.ClosedChannelException - If this channel is closed.java.io.IOException - If an error occursjava.lang.SecurityException - If a security manager has been installed and
it does not permit datagrams to be sent to the given address.public abstract java.net.DatagramSocket socket()
public abstract int write(java.nio.ByteBuffer src) throws java.io.IOException
write in interface WritableByteChanneljava.io.IOException - If an error occurs.NotYetConnectedException - The channel's socket is not connected.public abstract long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
write in interface GatheringByteChanneljava.io.IOException - If an error occurs.NotYetConnectedException - The channel's socket is not connected.public final int validOps()
validOps in class SelectableChannelNotYetConnectedException - The channel's socket is not connected.