DatagramChannel implementation that works with junixsocket.
| Modifier and Type | Field and Description |
|---|---|
| private final AFDatagramSocket |
| Access | Constructor and Description |
|---|---|
| protected | AFDatagramChannel(AFSelectorProvider<A>
The corresponding selectorProvider, AFDatagramSocket<A> SelectorProvider.The corresponding socket)Socket.Creates a new |
| Modifier and Type | Method and Description |
|---|---|
| public final AFDatagramChannel | bind(SocketAddress
The address to bind the socket, or local)null to bind the socket
to an automatically assigned socket addressImplements abstract java. Implements java. Binds the channel's socket to a local address. |
| public final AFDatagramChannel | connect(SocketAddress
The remote address to which this channel is to be connected remote)Implements abstract java. Connects this channel's socket. |
| public final AFDatagramChannel | disconnect()
Implements abstract java. Disconnects this channel's socket. |
| public final void | ensureAncillaryReceiveBufferSize(int
The minimum size (in bytes). minSize)Implements org. Ensures a minimum ancillary receive buffer size. |
| pack-priv final AFSocketCore | |
| protected final AFDatagramSocket | |
| public final int | getAncillaryReceiveBufferSize()
Implements org. Returns the size of the receive buffer for ancillary messages (in bytes). |
| public final FileDescriptor | getFileDescriptor()
Implements org. Returns the corresponding |
| public final @Nullable A | getLocalAddress()
Implements abstract java. Implements java. Returns the socket address that this channel's socket is bound to. |
| public final @Nullable A | getLocalSocketAddress()
Implements org. Returns the socket's local socket address, or |
| public final <T> T | getOption(SocketOption<T>
The socket option name)Implements java. Returns the value of a socket option. |
| public final @Nullable A | getRemoteAddress()
Implements abstract java. Returns the remote address to which this channel's socket is connected. |
| public final @Nullable A | getRemoteSocketAddress()
Implements org. Returns the socket's remote socket address, or |
| protected final void | implCloseSelectableChannel()
Implements abstract java. Closes this selectable channel. |
| protected final void | implConfigureBlocking(boolean
If block)true then this channel will be placed in
blocking mode; if false then it will be placed
non-blocking modeImplements abstract java. Adjusts this channel's blocking mode. |
| public final boolean | Returns: true if the socket successfully bound to an addressReturns the binding state of the socket. |
| public final boolean | isConnected()
Implements abstract java. Tells whether or not this channel's socket is connected. |
| public final boolean | |
| public final MembershipKey | join(InetAddress
The multicast address to join group, NetworkInterface The network interface on which to join the group interf)Implements java. Joins a multicast group to begin receiving all datagrams sent to the group, returning a membership key. |
| public final MembershipKey | join(InetAddress
The multicast address to join group, NetworkInterface The network interface on which to join the group interf, InetAddress The source address source)Implements java. Joins a multicast group to begin receiving datagrams sent to the group from a given source address. |
| public static DatagramChannel | Returns: The newDatagramChannel.The protocol family. family)Hides java. Opens a datagram channel. |
| public final int | read(ByteBuffer
The buffer into which bytes are to be transferred dst)Implements abstract java. Implements java. Reads a datagram from this channel. |
| public final long | read(ByteBuffer[]
The buffers into which bytes are to be transferred dsts, int The offset within the buffer array of the first buffer into
which bytes are to be transferred; must be non-negative and no
larger than offset, int dsts.lengthThe maximum number of buffers to be accessed; must be
non-negative and no larger than
length)dsts.length - offsetImplements abstract java. Implements java. Reads a datagram from this channel. |
| public final A | receive(ByteBuffer
The buffer into which the datagram is to be transferred dst)Implements abstract java. Receives a datagram via this channel. |
| public final int | send(ByteBuffer
The buffer containing the datagram to be sent src, SocketAddress The address to which the datagram is to be sent target)Implements abstract java. Sends a datagram via this channel. |
| public final void | setAncillaryReceiveBufferSize(int
The size. size)Implements org. Sets the size of the receive buffer for ancillary messages (in bytes). |
| public final void | setDeleteOnClose(boolean
Enabled if b)true.Enables/disables deleting this |
| public final <T> AFDatagramChannel | setOption(SocketOption<T>
The socket option name, T The value of the socket option. A value of value)null may be
a valid value for some socket options.Implements abstract java. Implements java. Sets the value of a socket option. |
| public void | setShutdownOnClose(boolean
true if enabled.Implements org. Configures whether the socket should be shutdown upon |
| public final AFDatagramSocket | socket()
Implements abstract java. Retrieves a datagram socket associated with this channel. |
| public final Set | supportedOptions()
Implements java. Returns a set of the socket options supported by this channel. |
| public final int | write(ByteBuffer
The buffer from which bytes are to be retrieved src)Implements abstract java. Implements java. Writes a datagram to this channel. |
| public final long | write(ByteBuffer[]
The buffers from which bytes are to be retrieved srcs, int The offset within the buffer array of the first buffer from
which bytes are to be retrieved; must be non-negative and no
larger than offset, int srcs.lengthThe maximum number of buffers to be accessed; must be
non-negative and no larger than
length)srcs.length - offsetImplements abstract java. Implements java. Writes a datagram to this channel. |
| afSocket | back to summary |
|---|---|
| private final AFDatagramSocket<A> afSocket | |
| AFDatagramChannel | back to summary |
|---|---|
| protected AFDatagramChannel(AFSelectorProvider<A> selectorProvider, AFDatagramSocket<A> socket) Creates a new
| |
| bind | back to summary |
|---|---|
| public final AFDatagramChannel Implements abstract java. Implements java. Doc from java. Binds the channel's socket to a local address. This method is used to establish an association between the socket and
a local address. Once an association is established then the socket remains
bound until the channel is closed. If the
| |
| connect | back to summary |
|---|---|
| public final AFDatagramChannel Implements abstract java. Doc from java. Connects this channel's socket. The channel's socket is configured so that it only receives datagrams from, and sends datagrams to, the given remote peer address. Once connected, datagrams may not be received from or sent to any other address. Datagrams in the channel's socket receive buffer, which have not been received before invoking this method, may be discarded. The channel's socket remains connected until it is explicitly disconnected or until it is closed. This method may be invoked at any time. If another thread has
already initiated a read or write operation upon this channel, then an
invocation of this method will block until any such operation is
complete. If this channel's socket is not bound then this method will
first cause the socket to be bound to an address that is assigned
automatically, as if invoking the
| |
| disconnect | back to summary |
|---|---|
| public final AFDatagramChannel Implements abstract java. Doc from java. Disconnects this channel's socket. The channel's socket is configured so that it can receive datagrams from, and sends datagrams to, any remote address. This method may be invoked at any time. If another thread has already initiated a read or write operation upon this channel, then an invocation of this method will block until any such operation is complete. If this channel's socket is not connected, or if the channel is closed, then invoking this method has no effect.
| |
| ensureAncillaryReceiveBufferSize | back to summary |
|---|---|
| public final void ensureAncillaryReceiveBufferSize(int minSize) Implements org. Doc from org. Ensures a minimum ancillary receive buffer size.
| |
| getAFCore | back to summary |
|---|---|
| pack-priv final AFSocketCore getAFCore() | |
| getAFSocket | back to summary |
|---|---|
| protected final AFDatagramSocket Returns the corresponding
| |
| getAncillaryReceiveBufferSize | back to summary |
|---|---|
| public final int getAncillaryReceiveBufferSize() Implements org. Doc from org. Returns the size of the receive buffer for ancillary messages (in bytes).
| |
| getFileDescriptor | back to summary |
|---|---|
| public final FileDescriptor getFileDescriptor() throws IOException Implements org. Doc from org. Returns the corresponding
| |
| getLocalAddress | back to summary |
|---|---|
| public final @Nullable A getLocalAddress() throws IOException Implements abstract java. Implements java. Doc from java. Returns the socket address that this channel's socket is bound to. Where the channel is
If the channel's socket was initially bound to the wildcard address and
is now
| |
| getLocalSocketAddress | back to summary |
|---|---|
| public final @Nullable A getLocalSocketAddress() Implements org. Doc from org. Returns the socket's local socket address, or | |
| getOption | back to summary |
|---|---|
| public final <T> T getOption(SocketOption<T> name) throws IOException Implements java. Doc from java. Returns the value of a socket option.
| |
| getRemoteAddress | back to summary |
|---|---|
| public final @Nullable A getRemoteAddress() throws IOException Implements abstract java. Doc from java. Returns the remote address to which this channel's socket is connected.
| |
| getRemoteSocketAddress | back to summary |
|---|---|
| public final @Nullable A getRemoteSocketAddress() Implements org. Doc from org. Returns the socket's remote socket address, or | |
| implCloseSelectableChannel | back to summary |
|---|---|
| protected final void implCloseSelectableChannel() throws IOException Implements abstract java. Doc from java. Closes this selectable channel. This method is invoked by the An implementation of this method must arrange for any other thread that is blocked in an I/O operation upon this channel to return immediately, either by throwing an exception or by returning normally.
| |
| implConfigureBlocking | back to summary |
|---|---|
| protected final void implConfigureBlocking(boolean block) throws IOException Implements abstract java. Doc from java. Adjusts this channel's blocking mode. This method is invoked by the
| |
| isBound | back to summary |
|---|---|
| public final boolean isBound() Returns the binding state of the socket.
| |
| isConnected | back to summary |
|---|---|
| public final boolean isConnected() Implements abstract java. Doc from java. Tells whether or not this channel's socket is connected. | |
| isDeleteOnClose | back to summary |
|---|---|
| public final boolean isDeleteOnClose() Checks if this
| |
| join | back to summary |
|---|---|
| public final MembershipKey join(InetAddress group, NetworkInterface interf) throws IOException Implements java. Doc from java. Joins a multicast group to begin receiving all datagrams sent to the group, returning a membership key. If this channel is currently a member of the group on the given
interface to receive all datagrams then the membership key, representing
that membership, is returned. Otherwise this channel joins the group and
the resulting new membership key is returned. The resulting membership key
is not A multicast channel may join several multicast groups, including the same group on more than one interface. An implementation may impose a limit on the number of groups that may be joined at the same time.
| |
| join | back to summary |
|---|---|
| public final MembershipKey join(InetAddress group, NetworkInterface interf, InetAddress source) throws IOException Implements java. Doc from java. Joins a multicast group to begin receiving datagrams sent to the group from a given source address. If this channel is currently a member of the group on the given
interface to receive datagrams from the given source address then the
membership key, representing that membership, is returned. Otherwise this
channel joins the group and the resulting new membership key is returned.
The resulting membership key is Membership is cumulative and this method may be invoked again with the same group and interface to allow receiving datagrams sent by other source addresses to the group.
| |
| open | back to summary |
|---|---|
| public static DatagramChannel open(ProtocolFamily family) throws IOException Hides java. Opens a datagram channel. The
If the
| |
| read | back to summary |
|---|---|
| public final int read(ByteBuffer dst) throws IOException Implements abstract java. Implements java. Doc from java. Reads a datagram from this channel. This method may only be invoked if this channel's socket is
connected, and it only accepts datagrams from the socket's peer. If
there are more bytes in the datagram than remain in the given buffer
then the remainder of the datagram is silently discarded. Otherwise
this method behaves exactly as specified in the
| |
| read | back to summary |
|---|---|
| public final long read(ByteBuffer[] dsts, int offset, int length) throws IOException Implements abstract java. Implements java. Doc from java. Reads a datagram from this channel. This method may only be invoked if this channel's socket is
connected, and it only accepts datagrams from the socket's peer. If
there are more bytes in the datagram than remain in the given buffers
then the remainder of the datagram is silently discarded. Otherwise
this method behaves exactly as specified in the
| |
| receive | back to summary |
|---|---|
| public final A receive(ByteBuffer dst) throws IOException Implements abstract java. Doc from java. Receives a datagram via this channel. If a datagram is immediately available, or if this channel is in
blocking mode and one eventually becomes available, then the datagram is
copied into the given byte buffer and its source address is returned.
If this channel is in non-blocking mode and a datagram is not
immediately available then this method immediately returns
The datagram is transferred into the given byte buffer starting at
its current position, as if by a regular This method may be invoked at any time. If another thread has
already initiated a read operation upon this channel, however, then an
invocation of this method will block until the first operation is
complete. If this channel's socket is not bound then this method will
first cause the socket to be bound to an address that is assigned
automatically, as if invoking the
| |
| send | back to summary |
|---|---|
| public final int send(ByteBuffer src, SocketAddress target) throws IOException Implements abstract java. Doc from java. Sends a datagram via this channel. If this channel is in non-blocking mode and there is sufficient room in the underlying output buffer, or if this channel is in blocking mode and sufficient room becomes available, then the remaining bytes in the given buffer are transmitted as a single datagram to the given target address. The datagram is transferred from the byte buffer as if by a regular
This method may be invoked at any time. If another thread has
already initiated a write operation upon this channel, however, then an
invocation of this method will block until the first operation is
complete. If this channel's socket is not bound then this method will
first cause the socket to be bound to an address that is assigned
automatically, as if by invoking the
| |
| setAncillaryReceiveBufferSize | back to summary |
|---|---|
| public final void setAncillaryReceiveBufferSize(int size) Implements org. Doc from org. Sets the size of the receive buffer for ancillary messages (in bytes). To disable handling ancillary messages, set it to 0 (default).
| |
| setDeleteOnClose | back to summary |
|---|---|
| public final void setDeleteOnClose(boolean b) Enables/disables deleting this
| |
| setOption | back to summary |
|---|---|
| public final <T> AFDatagramChannel Implements abstract java. Implements java. Doc from java. Sets the value of a socket option.
| |
| setShutdownOnClose | back to summary |
|---|---|
| public void setShutdownOnClose(boolean enabled) Implements org. Doc from org. Configures whether the socket should be shutdown upon
| |
| socket | back to summary |
|---|---|
| public final AFDatagramSocket Implements abstract java. Doc from java. Retrieves a datagram socket associated with this channel.
| |
| supportedOptions | back to summary |
|---|---|
| public final Set Implements java. Doc from java. Returns a set of the socket options supported by this channel. This method will continue to return the set of options even after the channel has been closed.
| |
| write | back to summary |
|---|---|
| public final int write(ByteBuffer src) throws IOException Implements abstract java. Implements java. Doc from java. Writes a datagram to this channel. This method may only be invoked if this channel's socket is
connected, in which case it sends datagrams directly to the socket's
peer. Otherwise it behaves exactly as specified in the
| |
| write | back to summary |
|---|---|
| public final long write(ByteBuffer[] srcs, int offset, int length) throws IOException Implements abstract java. Implements java. Doc from java. Writes a datagram to this channel. This method may only be invoked if this channel's socket is
connected, in which case it sends datagrams directly to the socket's
peer. Otherwise it behaves exactly as specified in the
| |