|
||||||||||
| 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, isShutDown, linger, logger, opToRegister, port, reuseAddress, role, selectionKeyHandler, selector, selectTimeout, serverSocket, serverSocketChannel, serverTimeout, socketTimeout, ssBackLog, stateHolder, tcpNoDelay, threadPool |
| Constructor Summary | |
|---|---|
UDPSelectorHandler()
|
|
UDPSelectorHandler(boolean isClient)
|
|
UDPSelectorHandler(Role role)
|
|
| Method Summary | |
|---|---|
void |
closeChannel(SelectableChannel channel)
Closes SelectableChannel |
protected void |
connect(SocketAddress remoteAddress,
SocketAddress localAddress,
CallbackHandler callbackHandler)
Register a CallBackHandler to this Selector. |
void |
copyTo(Copyable copy)
|
protected 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). |
Class<? extends SelectionKeyHandler> |
getPreferredSelectionKeyHandler()
Get the preffered SelectionKeyHandler implementation for this SelectorHandler. |
int |
getSocketNativeReceiveBufferSize()
|
int |
getSocketNativeSendBufferSize()
|
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 |
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 DatagramSocket datagramSocket
protected 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 IOException
preSelect in interface SelectorHandlerpreSelect in class TCPSelectorHandlerctx - Context
IOException
protected void connect(SocketAddress remoteAddress,
SocketAddress localAddress,
CallbackHandler callbackHandler)
throws IOException
connect in class TCPSelectorHandlerremoteAddress - remote address to connectlocalAddress - local address to bincallbackHandler - CallbackHandler
IOException
protected void onConnectOp(Context ctx,
SelectionKeyOP.ConnectSelectionKeyOP selectionKeyOp)
throws IOException
onConnectOp in class TCPSelectorHandlerIOExceptionpublic void shutdown()
shutdown in interface SelectorHandlershutdown in class TCPSelectorHandler
public boolean onAcceptInterest(SelectionKey key,
Context ctx)
throws IOException
onAcceptInterest in interface SelectorHandleronAcceptInterest in class TCPSelectorHandlerkey - SelectionKeyctx - Context
IOExceptionpublic 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 SocketException
sndBuffSize -
SocketException
public void setSocketNativeReceiveBufferSize(int recBuffSize)
throws SocketException
sndBuffSize -
SocketException
public int getSocketNativeReceiveBufferSize()
throws SocketException
SocketException
public int getSocketNativeSendBufferSize()
throws SocketException
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(SelectableChannel channel)
TCPSelectorHandlerSelectableChannel
closeChannel in interface SelectorHandlercloseChannel in class TCPSelectorHandlerprotected 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 | |||||||||