|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.TCPSelectorHandler
com.sun.grizzly.UDPSelectorHandler
public class UDPSelectorHandler
A SelectorHandler handles all java.nio.channels.Selector operations. One or more instance of a Selector are handled by SelectorHandler. The logic for processing of SelectionKey interest (OP_ACCEPT,OP_READ, etc.) is usually defined using an instance of SelectorHandler. This class represent a UDP implementation of a SelectorHandler. This class first bind a datagramSocketChannel to a UDP port and then start waiting for NIO events.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.sun.grizzly.TCPSelectorHandler |
|---|
TCPSelectorHandler.ConnectChannelOperation, TCPSelectorHandler.RegisterChannelOperation, TCPSelectorHandler.RegisterKeyOperation, TCPSelectorHandler.RunnableOperation, TCPSelectorHandler.SelectionKeyCancelOperation |
| Field Summary | |
|---|---|
protected java.nio.channels.DatagramChannel |
datagramChannel
The DatagramChannel. |
protected java.net.DatagramSocket |
datagramSocket
The datagramSocket instance. |
| Fields inherited from class com.sun.grizzly.TCPSelectorHandler |
|---|
asyncQueueReader, asyncQueueWriter, attributes, connectorInstanceHandler, inet, instanceHandler, isKeepAlive, isShutDown, linger, logger, portRange, postponedTasks, receiveBufferSize, reuseAddress, role, selectionKeyHandler, selector, selectorHandlerTasks, selectTimeout, sendBufferSize, serverSocket, serverSocketChannel, serverTimeout, socketTimeout, ssBackLog, stateHolder, tcpNoDelay, threadPool |
| Constructor Summary | |
|---|---|
UDPSelectorHandler()
|
|
UDPSelectorHandler(boolean isClient)
|
|
UDPSelectorHandler(Role role)
|
|
| Method Summary | |
|---|---|
void |
closeChannel(java.nio.channels.SelectableChannel channel)
Closes SelectableChannel |
void |
copyTo(Copyable copy)
|
protected java.util.concurrent.Callable<ConnectorHandler> |
getConnectorInstanceHandlerDelegate()
Return ConnectorInstanceHandler corresponding to the protocol |
int |
getLinger()
|
int |
getPortLowLevel()
Returns port number SelectorHandler is listening on
Similar to getPort(), but getting port number directly from
connection (ServerSocket, DatagramSocket). |
java.lang.Class<? extends SelectionKeyHandler> |
getPreferredSelectionKeyHandler()
Get the preffered SelectionKeyHandler implementation for this SelectorHandler. |
protected java.nio.channels.SelectableChannel |
getSelectableChannel(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
|
int |
getSocketNativeReceiveBufferSize()
|
int |
getSocketNativeSendBufferSize()
|
int |
getSocketTimeout()
|
int |
getSsBackLog()
|
boolean |
isTcpNoDelay()
Return the tcpNoDelay value used by the underlying accepted Sockets. |
boolean |
onAcceptInterest(java.nio.channels.SelectionKey key,
Context ctx)
Handle OP_ACCEPT. |
protected void |
onConnectOp(Context ctx,
TCPSelectorHandler.ConnectChannelOperation selectionKeyOp)
Handle new OP_CONNECT ops. |
void |
preSelect(Context ctx)
Before invoking Selector.select(), make sure the ServerScoketChannel has been created. |
Controller.Protocol |
protocol()
A token describing the protocol supported by an implementation of this interface |
void |
setLinger(int linger)
|
void |
setSocketNativeReceiveBufferSize(int recBuffSize)
|
void |
setSocketNativeSendBufferSize(int sendBuffSize)
|
void |
setSocketTimeout(int socketTimeout)
|
void |
setSsBackLog(int ssBackLog)
|
void |
setTcpNoDelay(boolean tcpNoDelay)
Enable (true) or disable (false) the underlying Socket's tcpNoDelay. |
void |
shutdown()
Shuntdown this instance by closing its Selector and associated channels. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.net.DatagramSocket datagramSocket
protected java.nio.channels.DatagramChannel datagramChannel
| Constructor Detail |
|---|
public UDPSelectorHandler()
public UDPSelectorHandler(boolean isClient)
public UDPSelectorHandler(Role role)
| Method Detail |
|---|
public void copyTo(Copyable copy)
copyTo in interface CopyablecopyTo in class TCPSelectorHandler
public void preSelect(Context ctx)
throws java.io.IOException
preSelect in interface SelectorHandlerpreSelect in class TCPSelectorHandlerctx - Context
java.io.IOException
protected java.nio.channels.SelectableChannel getSelectableChannel(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
throws java.io.IOException
getSelectableChannel in class TCPSelectorHandlerjava.io.IOException
protected void onConnectOp(Context ctx,
TCPSelectorHandler.ConnectChannelOperation selectionKeyOp)
throws java.io.IOException
onConnectOp in class TCPSelectorHandlerjava.io.IOExceptionpublic void shutdown()
shutdown in interface SelectorHandlershutdown in class TCPSelectorHandler
public boolean onAcceptInterest(java.nio.channels.SelectionKey key,
Context ctx)
throws java.io.IOException
onAcceptInterest in interface SelectorHandleronAcceptInterest in class TCPSelectorHandlerkey - SelectionKeyctx - Context
java.io.IOExceptionpublic java.lang.Class<? extends SelectionKeyHandler> getPreferredSelectionKeyHandler()
getPreferredSelectionKeyHandler in interface SelectorHandlergetPreferredSelectionKeyHandler in class TCPSelectorHandlerpublic Controller.Protocol protocol()
protocol in interface SelectorHandlerprotocol in class TCPSelectorHandlerpublic int getPortLowLevel()
TCPSelectorHandlerSelectorHandler is listening on
Similar to getPort(), but getting port number directly from
connection (ServerSocket, DatagramSocket).
So if default port number 0 was set during initialization, then getPort()
will return 0, but getPortLowLevel() will
return port number assigned by OS.
getPortLowLevel in class TCPSelectorHandlerSelectorHandler was not initialized for accepting connections.
public void setSocketNativeSendBufferSize(int sendBuffSize)
throws java.net.SocketException
sndBuffSize -
java.net.SocketException
public void setSocketNativeReceiveBufferSize(int recBuffSize)
throws java.net.SocketException
sndBuffSize -
java.net.SocketException
public int getSocketNativeReceiveBufferSize()
throws java.net.SocketException
java.net.SocketException
public int getSocketNativeSendBufferSize()
throws java.net.SocketException
java.net.SocketExceptionpublic int getSsBackLog()
getSsBackLog in class TCPSelectorHandlerpublic void setSsBackLog(int ssBackLog)
setSsBackLog in class TCPSelectorHandlerpublic boolean isTcpNoDelay()
TCPSelectorHandler
isTcpNoDelay in class TCPSelectorHandlerpublic void setTcpNoDelay(boolean tcpNoDelay)
TCPSelectorHandler
setTcpNoDelay in class TCPSelectorHandlerpublic int getLinger()
getLinger in class TCPSelectorHandlerpublic void setLinger(int linger)
setLinger in class TCPSelectorHandlerpublic int getSocketTimeout()
getSocketTimeout in class TCPSelectorHandlerpublic void setSocketTimeout(int socketTimeout)
setSocketTimeout in class TCPSelectorHandlerpublic void closeChannel(java.nio.channels.SelectableChannel channel)
TCPSelectorHandlerSelectableChannel
closeChannel in interface SelectorHandlercloseChannel in class TCPSelectorHandlerprotected java.util.concurrent.Callable<ConnectorHandler> getConnectorInstanceHandlerDelegate()
TCPSelectorHandlerConnectorInstanceHandler corresponding to the protocol
getConnectorInstanceHandlerDelegate in class TCPSelectorHandler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||