Package com.google.code.yanf4j.nio
Class TCPController
java.lang.Object
com.google.code.yanf4j.core.impl.AbstractController
com.google.code.yanf4j.nio.impl.NioController
com.google.code.yanf4j.nio.impl.SocketChannelController
com.google.code.yanf4j.nio.TCPController
- All Implemented Interfaces:
Controller
,ControllerLifeCycle
,SelectionKeyHandler
Controller for tcp server
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
Accept backlog queue sizeprivate int
private int
private int
private ServerSocketChannel
Fields inherited from class com.google.code.yanf4j.nio.impl.SocketChannelController
soLingerOn
Fields inherited from class com.google.code.yanf4j.nio.impl.NioController
selectorManager, selectorPoolSize
Fields inherited from class com.google.code.yanf4j.core.impl.AbstractController
codecFactory, configuration, dispatchMessageDispatcher, dispatchMessageThreadCount, handler, handleReadWriteConcurrently, localSocketAddress, log, readEventDispatcher, readThreadCount, sessionSet, sessionTimeout, socketOptions, soTimeout, started, stateListeners, statistics, statisticsInterval, writeEventDispatcher, writeThreadCount
-
Constructor Summary
ConstructorsConstructorDescriptionTCPController
(Configuration configuration) TCPController
(Configuration configuration, CodecFactory codecFactory) TCPController
(Configuration configuration, Handler handler, CodecFactory codecFactory) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
void
closeChannel
(Selector selector) protected void
doStart()
Inner startupint
void
onAccept
(SelectionKey selectionKey) void
setBacklog
(int backlog) void
setPerformancePreferences
(int connectionTime, int latency, int bandwidth) void
unbind()
Methods inherited from class com.google.code.yanf4j.nio.impl.SocketChannelController
buildSession, configureSocketChannel, dispatchReadEvent, dispatchWriteEvent, setSoLinger
Methods inherited from class com.google.code.yanf4j.nio.impl.NioController
bind, buildSessionConfig, closeSelectionKey, getSelectorManager, getSelectorPoolSize, initialSelectorManager, onRead, onWrite, setSelectorPoolSize, start0, stop0
Methods inherited from class com.google.code.yanf4j.core.impl.AbstractController
addStateListener, bind, buildQueue, checkStatisticsForRestart, getCodecFactory, getConfiguration, getDispatchMessageThreadCount, getHandler, getLocalSocketAddress, getPort, getReadThreadCount, getReceiveThroughputLimit, getSendThroughputLimit, getSessionIdleTimeout, getSessionSet, getSessionTimeout, getSocketOption, getSoTimeout, getStatistics, getWriteThreadCount, isHandleReadWriteConcurrently, isStarted, notifyAllSessionClosed, notifyException, notifyReady, notifyStarted, notifyStopped, onConnect, registerSession, removeStateListener, setCodecFactory, setConfiguration, setDispatchMessageThreadCount, setHandler, setHandleReadWriteConcurrently, setLocalSocketAddress, setReadThreadCount, setReceiveThroughputLimit, setSendThroughputLimit, setSessionIdleTimeout, setSessionTimeout, setSocketOption, setSocketOptions, setSoTimeout, setWriteThreadCount, start, stop, unregisterSession
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.code.yanf4j.nio.SelectionKeyHandler
onConnect
-
Field Details
-
serverSocketChannel
-
backlog
private int backlogAccept backlog queue size -
connectionTime
private int connectionTime -
latency
private int latency -
bandwidth
private int bandwidth
-
-
Constructor Details
-
TCPController
public TCPController() -
TCPController
-
TCPController
-
TCPController
-
-
Method Details
-
getBacklog
public int getBacklog() -
setBacklog
public void setBacklog(int backlog) -
setPerformancePreferences
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) -
doStart
Description copied from class:NioController
Inner startup- Specified by:
doStart
in classNioController
- Throws:
IOException
-
onAccept
- Specified by:
onAccept
in interfaceSelectionKeyHandler
- Overrides:
onAccept
in classAbstractController
- Throws:
IOException
-
closeAcceptChannel
private void closeAcceptChannel(SelectionKey sk, SocketChannel sc) throws IOException, SocketException - Parameters:
sk
-sc
-- Throws:
IOException
SocketException
-
closeChannel
- Throws:
IOException
-
unbind
- Throws:
IOException
-