org.glassfish.grizzly.nio.transport
Class UDPNIOConnection

java.lang.Object
  extended by org.glassfish.grizzly.nio.NIOConnection
      extended by org.glassfish.grizzly.nio.transport.UDPNIOConnection
All Implemented Interfaces:
AttributeStorage, Closeable<Connection>, Connection<java.net.SocketAddress>, MonitoringAware<ConnectionProbe>, Readable<java.net.SocketAddress>, Writable<java.net.SocketAddress>
Direct Known Subclasses:
UDPNIOServerConnection

public class UDPNIOConnection
extends NIOConnection

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
asyncReadQueue, asyncWriteQueue, attributes, channel, closeFlag, isBlocking, isStandalone, maxAsyncWriteQueueSize, monitoringConfig, processor, processorSelector, readBufferSize, readTimeoutMillis, selectionKey, selectorRunner, transport, writeBufferSize, writeTimeoutMillis, zeroByteReadCount
 
Constructor Summary
UDPNIOConnection(UDPNIOTransport transport, java.nio.channels.DatagramChannel channel)
           
 
Method Summary
 java.net.SocketAddress getLocalAddress()
          Returns the local address of this Connection, or null if it is unconnected.
 java.net.SocketAddress getPeerAddress()
          Returns the address of the endpoint this Connection is connected to, or null if it is unconnected.
 boolean isConnected()
           
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 preClose()
           
 void register()
           
protected  void resetProperties()
           
 void setReadBufferSize(int readBufferSize)
          Set the default size of Buffers, which will be allocated for reading data from Connection.
protected  void setSelectionKey(java.nio.channels.SelectionKey selectionKey)
           
protected  void setSelectorRunner(SelectorRunner selectorRunner)
           
 void setWriteBufferSize(int writeBufferSize)
          Set the default size of Buffers, which will be allocated for writing data to Connection.
 java.lang.String toString()
           
 
Methods inherited from class org.glassfish.grizzly.nio.NIOConnection
addCloseListener, attachToSelectorRunner, checkEmptyRead, close, close, close0, closeSilently, configureBlocking, configureStandalone, detachSelectorRunner, disableIOEvent, enableIOEvent, getAsyncReadQueue, getAsyncWriteQueue, getAttributes, getChannel, getMaxAsyncWriteQueueSize, getMonitoringConfig, getProcessor, getProcessorSelector, getReadBufferSize, getReadTimeout, getSelectionKey, getSelectorRunner, getTransport, getWriteBufferSize, getWriteTimeout, isBlocking, isOpen, isStandalone, notifyConnectionError, notifyIOEventDisabled, notifyIOEventEnabled, notifyIOEventReady, notifyProbesAccept, notifyProbesBind, notifyProbesClose, notifyProbesConnect, notifyProbesError, notifyProbesRead, notifyProbesWrite, obtainProcessor, obtainProcessorState, read, read, removeCloseListener, setChannel, setMaxAsyncWriteQueueSize, setProcessor, setProcessorSelector, setReadTimeout, setWriteTimeout, simulateIOEvent, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UDPNIOConnection

public UDPNIOConnection(UDPNIOTransport transport,
                        java.nio.channels.DatagramChannel channel)
Method Detail

isConnected

public boolean isConnected()

register

public void register()
              throws java.io.IOException
Throws:
java.io.IOException

setSelectionKey

protected void setSelectionKey(java.nio.channels.SelectionKey selectionKey)
Overrides:
setSelectionKey in class NIOConnection

setSelectorRunner

protected void setSelectorRunner(SelectorRunner selectorRunner)
Overrides:
setSelectorRunner in class NIOConnection

preClose

protected void preClose()
Specified by:
preClose in class NIOConnection

getPeerAddress

public java.net.SocketAddress 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

public java.net.SocketAddress 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()

setReadBufferSize

public void setReadBufferSize(int readBufferSize)
Description copied from interface: Connection
Set the default size of Buffers, which will be allocated for reading data from Connection.

Specified by:
setReadBufferSize in interface Connection<java.net.SocketAddress>
Overrides:
setReadBufferSize in class NIOConnection
Parameters:
readBufferSize - the default size of Buffers, which will be allocated for reading data from Connection.

setWriteBufferSize

public void setWriteBufferSize(int writeBufferSize)
Description copied from interface: Connection
Set the default size of Buffers, which will be allocated for writing data to Connection.

Specified by:
setWriteBufferSize in interface Connection<java.net.SocketAddress>
Overrides:
setWriteBufferSize in class NIOConnection
Parameters:
writeBufferSize - the default size of Buffers, which will be allocated for writing data to Connection.

onConnect

protected final void onConnect()
                        throws java.io.IOException
Method will be called, when the connection gets connected.

Throws:
java.io.IOException

onRead

protected final void onRead(Buffer data,
                            int size)
Method will be called, when some data was read on the connection


onWrite

protected final void onWrite(Buffer data,
                             int size)
Method will be called, when some data was written on the connection


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2012 Oracle Corporation. All Rights Reserved.