java.lang.Object
org.glassfish.grizzly.nio.NIOConnection
org.glassfish.grizzly.nio.transport.UDPNIOConnection
- All Implemented Interfaces:
AttributeStorage
,Closeable
,Connection<SocketAddress>
,MonitoringAware<ConnectionProbe>
,OutputSink
,Readable<SocketAddress>
,Writeable<SocketAddress>
- Direct Known Subclasses:
UDPNIOServerConnection
Connection
implementation for the UDPNIOTransport
- Author:
- Alexey Stashok
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.glassfish.grizzly.Connection
Connection.CloseListener, Connection.CloseType
-
Field Summary
Fields inherited from class org.glassfish.grizzly.nio.NIOConnection
attributes, channel, connectCloseSemaphoreUpdater, isBlocking, isStandalone, maxAsyncWriteQueueSize, monitoringConfig, NOTIFICATION_CLOSED_COMPLETE, NOTIFICATION_INITIALIZED, processor, processorSelector, readTimeoutMillis, selectionKey, selectorRunner, transport, writeTimeoutMillis, zeroByteReadCount
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.protected void
Enables OP_READ if it has never been enabled before.Returns the local address of this Connection, or null if it is unconnected.Returns the address of the endpoint this Connection is connected to, or null if it is unconnected.int
Get the default size ofBuffer
s, which will be allocated for reading data fromConnection
.int
Get the default size ofBuffer
s, which will be allocated for writing data toConnection
.boolean
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 theOutputSink
to invoke the providedWriteHandler
when it is possible to write more bytes (or characters).void
notifyCanWrite
(WriteHandler handler, int length) Deprecated.protected boolean
protected final void
Method will be called, when the connection gets connected.protected final void
Method will be called, when some data was read on the connectionprotected final void
Method will be called, when some data was written on the connectionprotected final void
void
setReadBufferSize
(int readBufferSize) Set the default size ofBuffer
s, which will be allocated for reading data fromConnection
.protected void
setSelectionKey
(SelectionKey selectionKey) protected void
setSelectorRunner
(SelectorRunner selectorRunner) void
setWriteBufferSize
(int writeBufferSize) Set the default size ofBuffer
s, which will be allocated for writing data toConnection
.toString()
void
unblock
(InetAddress group, NetworkInterface networkInterface, InetAddress source) Unblocks multicast datagrams from the given source address.Methods inherited from class org.glassfish.grizzly.nio.NIOConnection
addCloseListener, addCloseListener, assertOpen, attachToSelectorRunner, checkEmptyRead, close, close, closeFuture, closeGracefully0, closeSilently, closeWithReason, configureBlocking, configureStandalone, detachSelectorRunner, disableIOEvent, doClose, enableIOEvent, executeInEventThread, getAsyncReadQueue, getAsyncWriteQueue, getAttributes, getChannel, getCloseReason, getId, getMaxAsyncWriteQueueSize, getMemoryManager, getMonitoringConfig, getProcessor, getProcessorSelector, getReadTimeout, getSelectionKey, getSelectorRunner, getTransport, getWriteTimeout, isBlocking, isClosed, 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, terminate, terminate0, terminateSilently, terminateWithReason, write, write, write, write, write
-
Constructor Details
-
UDPNIOConnection
-
-
Method Details
-
isConnected
public boolean isConnected() -
join
Joins a multicast group to begin receiving all datagrams sent to the group. If this connection is currently a member of the group on the given interface to receive all datagrams then this method call has no effect. Otherwise this connection joins the requested group and channel's membership in not source-specific. A multicast connection 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.- Parameters:
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the group- Throws:
IOException
-
join
public void join(InetAddress group, NetworkInterface networkInterface, InetAddress source) throws IOException Joins a multicast group to begin receiving datagrams sent to the group from a given source address. If this connection is currently a member of the group on the given interface to receive datagrams from the given source address then this method call has no effect. Otherwise this connection joins the group and depending on the source parameter value (whether it's not null or null value) the connection's membership is or is not source-specific. 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.- Parameters:
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupsource
- The source address- Throws:
IOException
-
drop
Drops non-source specific membership in a multicast group. If this connection doesn't have non-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 group membership.- Parameters:
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the group- Throws:
IOException
-
drop
public void drop(InetAddress group, NetworkInterface networkInterface, InetAddress source) throws IOException Drops membership in a multicast group. If the source parameter is null - this method call is equivalent todrop(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.- Parameters:
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupsource
- The source address- Throws:
IOException
-
dropAll
Drops all active membership in a multicast group. If this connection doesn't have any type of membership in the group on the given interface to receive datagrams then this method call has no effect. Otherwise this connection drops all types of the group membership.- Parameters:
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the group- Throws:
IOException
-
block
public void block(InetAddress group, NetworkInterface networkInterface, InetAddress source) throws IOException Blocks multicast datagrams from the given source address. If this connection has non-source specific membership in the group on the given interface then this method blocks multicast datagrams from the given source address. If the given source address is already blocked then this method has no effect.- Parameters:
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupsource
- The source address to block- Throws:
IOException
-
unblock
public void unblock(InetAddress group, NetworkInterface networkInterface, InetAddress source) throws IOException Unblocks multicast datagrams from the given source address. If this connection has non-source specific membership in the group on the given interface and specified source address was previously blocked usingblock(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.- Parameters:
group
- The multicast address to joinnetworkInterface
- The network interface on which to join the groupsource
- The source address to block- Throws:
IOException
-
setSelectionKey
- Overrides:
setSelectionKey
in classNIOConnection
-
setSelectorRunner
- Overrides:
setSelectorRunner
in classNIOConnection
-
notifyReady
protected boolean notifyReady() -
getPeerAddress
Returns the address of the endpoint this Connection is connected to, or null if it is unconnected.- Returns:
- the address of the endpoint this Connection is connected to, or null if it is unconnected.
-
getLocalAddress
Returns the local address of this Connection, or null if it is unconnected.- Returns:
- the local address of this Connection, or null if it is unconnected.
-
resetProperties
protected final void resetProperties() -
getReadBufferSize
public int getReadBufferSize()Get the default size ofBuffer
s, which will be allocated for reading data fromConnection
. The value less or equal to zero will be ignored.- Returns:
- the default size of
Buffer
s, which will be allocated for reading data fromConnection
.
-
setReadBufferSize
public void setReadBufferSize(int readBufferSize) Set the default size ofBuffer
s, which will be allocated for reading data fromConnection
. The value less or equal to zero will be ignored.- Parameters:
readBufferSize
- the default size ofBuffer
s, which will be allocated for reading data fromConnection
.
-
getWriteBufferSize
public int getWriteBufferSize()Get the default size ofBuffer
s, which will be allocated for writing data toConnection
.- Returns:
- the default size of
Buffer
s, which will be allocated for writing data toConnection
.
-
setWriteBufferSize
public void setWriteBufferSize(int writeBufferSize) Set the default size ofBuffer
s, which will be allocated for writing data toConnection
.- Parameters:
writeBufferSize
- the default size ofBuffer
s, which will be allocated for writing data toConnection
.
-
enableInitialOpRead
Description copied from class:NIOConnection
Enables OP_READ if it has never been enabled before.- Overrides:
enableInitialOpRead
in classNIOConnection
- Throws:
IOException
-
onConnect
Method will be called, when the connection gets connected.- Throws:
IOException
-
onRead
Method will be called, when some data was read on the connection -
onWrite
Method will be called, when some data was written on the connection -
canWrite
public boolean canWrite()- Returns:
true
if a write to thisOutputSink
will succeed, otherwise returnsfalse
.
-
canWrite
Deprecated.- Parameters:
length
- specifies the number of bytes (or characters) that require writing- Returns:
true
if a write to thisOutputSink
will succeed, otherwise returnsfalse
.
-
notifyCanWrite
Instructs theOutputSink
to invoke the providedWriteHandler
when it is possible to write more bytes (or characters). Note that once theWriteHandler
has been notified, it will not be considered for notification again at a later point in time.- Parameters:
writeHandler
- theWriteHandler
that should be notified when it's possible to write more data.
-
notifyCanWrite
Deprecated.Instructs theOutputSink
to invoke the providedWriteHandler
when it is possible to writelength
bytes (or characters). Note that once theWriteHandler
has been notified, it will not be considered for notification again at a later point in time.- Parameters:
handler
- theWriteHandler
that should be notified when it's possible to writelength
bytes.length
- the number of bytes or characters that require writing.
-
toString
-