|
||||||||||
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.
Field Summary | |
---|---|
protected DatagramChannel |
datagramChannel
The DatagramChannel. |
protected DatagramSocket |
datagramSocket
The datagramSocket instance. |
Fields inherited from class com.sun.grizzly.TCPSelectorHandler |
---|
asyncQueueReader, asyncQueueWriter, attributes, connectorInstanceHandler, inet, instanceHandler, isClient, isShutDown, linger, logger, opToRegister, pipeline, port, reuseAddress, selectionKeyHandler, selector, selectTimeout, serverSocket, serverSocketChannel, serverTimeout, socketTimeout, ssBackLog, stateHolder, tcpNoDelay |
Constructor Summary | |
---|---|
UDPSelectorHandler()
|
|
UDPSelectorHandler(boolean isClient)
|
Method Summary | |
---|---|
void |
closeChannel(SelectableChannel channel)
Closes SelectableChannel |
void |
copyTo(Copyable copy)
Copies current object content to copy object |
protected Callable<ConnectorHandler> |
getConnectorInstanceHandlerDelegate()
Return ConnectorInstanceHandler |
int |
getLinger()
|
int |
getPortLowLevel()
Returns port number SelectorHandler is listening on
Similar to getPort() , but getting port number directly from
connection (ServerSocket , DatagramSocket ). |
Class<? extends SelectionKeyHandler> |
getPreferredSelectionKeyHandler()
Get the preffered SelectionKeyHandler implementation for this SelectorHandler. |
int |
getSocketTimeout()
|
int |
getSsBackLog()
|
boolean |
isTcpNoDelay()
Return the tcpNoDelay value used by the underlying accepted Sockets. |
boolean |
onAcceptInterest(SelectionKey key,
Context ctx)
Handle OP_ACCEPT. |
protected void |
onConnectOp(Context ctx,
SelectionKeyOP.ConnectSelectionKeyOP 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 |
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 DatagramSocket datagramSocket
protected DatagramChannel datagramChannel
Constructor Detail |
---|
public UDPSelectorHandler()
public UDPSelectorHandler(boolean isClient)
Method Detail |
---|
public void copyTo(Copyable copy)
Copyable
copyTo
in interface Copyable
copyTo
in class TCPSelectorHandler
copy
- represents target object, where current object's content will be copiedpublic void preSelect(Context ctx) throws IOException
preSelect
in interface SelectorHandler
preSelect
in class TCPSelectorHandler
ctx
- Context
IOException
protected void onConnectOp(Context ctx, SelectionKeyOP.ConnectSelectionKeyOP selectionKeyOp) throws IOException
onConnectOp
in class TCPSelectorHandler
IOException
public void shutdown()
shutdown
in interface SelectorHandler
shutdown
in class TCPSelectorHandler
public boolean onAcceptInterest(SelectionKey key, Context ctx) throws IOException
onAcceptInterest
in interface SelectorHandler
onAcceptInterest
in class TCPSelectorHandler
key
- SelectionKey
ctx
- Context
IOException
public Class<? extends SelectionKeyHandler> getPreferredSelectionKeyHandler()
getPreferredSelectionKeyHandler
in interface SelectorHandler
getPreferredSelectionKeyHandler
in class TCPSelectorHandler
public Controller.Protocol protocol()
protocol
in interface SelectorHandler
protocol
in class TCPSelectorHandler
public int getPortLowLevel()
TCPSelectorHandler
SelectorHandler
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 TCPSelectorHandler
SelectorHandler
was not initialized for accepting connections.public int getSsBackLog()
getSsBackLog
in class TCPSelectorHandler
public void setSsBackLog(int ssBackLog)
setSsBackLog
in class TCPSelectorHandler
public boolean isTcpNoDelay()
TCPSelectorHandler
isTcpNoDelay
in class TCPSelectorHandler
public void setTcpNoDelay(boolean tcpNoDelay)
TCPSelectorHandler
setTcpNoDelay
in class TCPSelectorHandler
public int getLinger()
getLinger
in class TCPSelectorHandler
public void setLinger(int linger)
setLinger
in class TCPSelectorHandler
public int getSocketTimeout()
getSocketTimeout
in class TCPSelectorHandler
public void setSocketTimeout(int socketTimeout)
setSocketTimeout
in class TCPSelectorHandler
public void closeChannel(SelectableChannel channel)
TCPSelectorHandler
SelectableChannel
closeChannel
in interface SelectorHandler
closeChannel
in class TCPSelectorHandler
protected Callable<ConnectorHandler> getConnectorInstanceHandlerDelegate()
TCPSelectorHandler
ConnectorInstanceHandler corresponding to the protocol
- Overrides:
getConnectorInstanceHandlerDelegate
in class TCPSelectorHandler
- Returns:
factory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |