public class UDPNIOConnection extends NIOConnection
Connection
implementation
for the UDPNIOTransport
Connection.CloseListener, Connection.CloseType
asyncReadQueue, asyncWriteQueue, attributes, channel, closeTypeFlag, connectCloseSemaphor, isBlocking, isStandalone, maxAsyncWriteQueueSize, monitoringConfig, NOTIFICATION_CLOSED_COMPLETE, NOTIFICATION_INITIALIZED, processor, processorSelector, readTimeoutMillis, selectionKey, selectorRunner, transport, writeTimeoutMillis, zeroByteReadCount
Constructor and Description |
---|
UDPNIOConnection(UDPNIOTransport transport,
DatagramChannel channel) |
Modifier and Type | Method and Description |
---|---|
void |
block(InetAddress group,
NetworkInterface networkInterface,
InetAddress source)
Blocks multicast datagrams from the given source address.
|
boolean |
canWrite() |
boolean |
canWrite(int length)
Deprecated.
|
void |
drop(InetAddress group,
NetworkInterface networkInterface)
Drops non-source specific membership in a multicast group.
|
void |
drop(InetAddress group,
NetworkInterface networkInterface,
InetAddress source)
Drops membership in a multicast group.
|
void |
dropAll(InetAddress group,
NetworkInterface networkInterface)
Drops all active membership in a multicast group.
|
SocketAddress |
getLocalAddress()
Returns the local address of this Connection,
or null if it is unconnected.
|
SocketAddress |
getPeerAddress()
Returns the address of the endpoint this Connection is
connected to, or null if it is unconnected.
|
int |
getReadBufferSize()
Get the default size of
Buffer s, which will be allocated for
reading data from Connection . |
int |
getWriteBufferSize()
Get the default size of
Buffer s, which will be allocated for
writing data to Connection . |
boolean |
isConnected() |
void |
join(InetAddress group,
NetworkInterface networkInterface)
Joins a multicast group to begin receiving all datagrams sent to the
group.
|
void |
join(InetAddress group,
NetworkInterface networkInterface,
InetAddress source)
Joins a multicast group to begin receiving datagrams sent to the group
from a given source address.
|
void |
notifyCanWrite(WriteHandler writeHandler)
Instructs the
OutputSink to invoke the provided
WriteHandler when it is possible to write more bytes (or characters). |
void |
notifyCanWrite(WriteHandler handler,
int length)
Deprecated.
|
protected boolean |
notifyReady() |
protected void |
onConnect()
Method will be called, when the connection gets connected.
|
protected void |
onRead(Buffer data,
int size)
Method will be called, when some data was read on the connection
|
protected void |
onWrite(Buffer data,
int size)
Method will be called, when some data was written on the connection
|
protected void |
resetProperties() |
void |
setReadBufferSize(int readBufferSize)
Set the default size of
Buffer s, which will be allocated for
reading data from Connection . |
protected void |
setSelectionKey(SelectionKey selectionKey) |
protected void |
setSelectorRunner(SelectorRunner selectorRunner) |
void |
setWriteBufferSize(int writeBufferSize)
Set the default size of
Buffer s, which will be allocated for
writing data to Connection . |
String |
toString() |
void |
unblock(InetAddress group,
NetworkInterface networkInterface,
InetAddress source)
Unblocks multicast datagrams from the given source address.
|
addCloseListener, addCloseListener, attachToSelectorRunner, checkEmptyRead, close, close, close0, closeSilently, configureBlocking, configureStandalone, detachSelectorRunner, disableIOEvent, enableIOEvent, getAsyncReadQueue, getAsyncWriteQueue, getAttributes, getChannel, getMaxAsyncWriteQueueSize, getMonitoringConfig, getProcessor, getProcessorSelector, getReadTimeout, getSelectionKey, getSelectorRunner, getTransport, getWriteTimeout, isBlocking, isOpen, isStandalone, notifyConnectionError, notifyIOEventDisabled, notifyIOEventEnabled, notifyIOEventReady, notifyProbesAccept, notifyProbesBind, notifyProbesClose, notifyProbesConnect, notifyProbesError, notifyProbesRead, notifyProbesWrite, obtainProcessor, obtainProcessorState, preClose, read, read, removeCloseListener, removeCloseListener, setChannel, setMaxAsyncWriteQueueSize, setProcessor, setProcessorSelector, setReadTimeout, setWriteTimeout, simulateIOEvent, write, write, write, write, write
public UDPNIOConnection(UDPNIOTransport transport, DatagramChannel channel)
public boolean isConnected()
public void join(InetAddress group, NetworkInterface networkInterface) throws IOException
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupIOException
public void join(InetAddress group, NetworkInterface networkInterface, InetAddress source) throws IOException
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupsource
- The source addressIOException
public void drop(InetAddress group, NetworkInterface networkInterface) throws IOException
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupIOException
public void drop(InetAddress group, NetworkInterface networkInterface, InetAddress source) throws IOException
drop(java.net.InetAddress, java.net.NetworkInterface)
.
If the source parameter is not null and this connection doesn't have
source specific membership in the group on the given interface to
receive datagrams then this method call has no effect.
Otherwise this connection drops the source specific group membership.group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupsource
- The source addressIOException
public void dropAll(InetAddress group, NetworkInterface networkInterface) throws IOException
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupIOException
public void block(InetAddress group, NetworkInterface networkInterface, InetAddress source) throws IOException
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupsource
- The source address to blockIOException
public void unblock(InetAddress group, NetworkInterface networkInterface, InetAddress source) throws IOException
block(java.net.InetAddress, java.net.NetworkInterface, java.net.InetAddress)
method
then this method unblocks multicast datagrams from the given source address.
If the given source address wasn't blocked then this method has no effect.group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupsource
- The source address to blockIOException
protected void setSelectionKey(SelectionKey selectionKey)
setSelectionKey
in class NIOConnection
protected void setSelectorRunner(SelectorRunner selectorRunner)
setSelectorRunner
in class NIOConnection
protected boolean notifyReady()
public SocketAddress getPeerAddress()
public SocketAddress getLocalAddress()
protected final void resetProperties()
public int getReadBufferSize()
Buffer
s, which will be allocated for
reading data from Connection
.
The value less or equal to zero will be ignored.Buffer
s, which will be allocated for
reading data from Connection
.public void setReadBufferSize(int readBufferSize)
Buffer
s, which will be allocated for
reading data from Connection
.
The value less or equal to zero will be ignored.readBufferSize
- the default size of Buffer
s, which will
be allocated for reading data from Connection
.public int getWriteBufferSize()
Buffer
s, which will be allocated for
writing data to Connection
.Buffer
s, which will be allocated for
writing data to Connection
.public void setWriteBufferSize(int writeBufferSize)
Buffer
s, which will be allocated for
writing data to Connection
.writeBufferSize
- the default size of Buffer
s, which will
be allocated for writing data to Connection
.protected final void onConnect() throws IOException
IOException
protected final void onRead(Buffer data, int size)
protected final void onWrite(Buffer data, int size)
public boolean canWrite()
true
if a write to this OutputSink
will succeed, otherwise returns false
.@Deprecated public boolean canWrite(int length)
length
- specifies the number of bytes (or characters) that require writingtrue
if a write to this OutputSink
will succeed, otherwise returns false
.public void notifyCanWrite(WriteHandler writeHandler)
OutputSink
to invoke the provided
WriteHandler
when it is possible to write more bytes (or characters).
Note that once the WriteHandler
has been notified, it will not
be considered for notification again at a later point in time.writeHandler
- the WriteHandler
that should be notified
when it's possible to write more data.@Deprecated public void notifyCanWrite(WriteHandler handler, int length)
OutputSink
to invoke the provided
WriteHandler
when it is possible to write length
bytes (or characters).
Note that once the WriteHandler
has been notified, it will not
be considered for notification again at a later point in time.handler
- the WriteHandler
that should be notified
when it's possible to write length
bytes.length
- the number of bytes or characters that require writing.Copyright © 2014 Oracle Corporation. All rights reserved.