├── .gitignore ├── 001.png ├── 002.png ├── 003.png ├── EchoServer ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── echoserver │ ├── EchoProtocolHandler.java │ ├── Main.java │ ├── package.html │ └── ssl │ ├── BogusSslContextFactory.java │ ├── BogusTrustManagerFactory.java │ ├── SslServerSocketFactory.java │ ├── SslSocketFactory.java │ └── package.html ├── HaikuValidationServer ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── haiku │ ├── Haiku.java │ ├── HaikuValidationServer.java │ ├── HaikuValidator.java │ ├── HaikuValidatorIoHandler.java │ ├── InvalidHaikuException.java │ ├── PhraseUtilities.java │ └── ToHaikuIoFilter.java ├── Long_TCP_Client ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── test │ └── LongTcpClient.java ├── Long_TCP_Server ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── test │ ├── ClientKeepAliveMessageFactoryImp.java │ ├── ClientSessionHandler.java │ ├── KeepAliveMessageFactoryImp.java │ ├── LongTcpServer.java │ ├── ServerKeepAliveMessageFactoryImp.java │ └── ServerSessionHandler.java ├── MemMonClient ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── udp │ └── client │ └── MemMonClient.java ├── MemoryMonitor ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── udp │ ├── ClientPanel.java │ ├── MemoryMonitor.java │ └── MemoryMonitorHandler.java ├── NetCatClient ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── netcat │ ├── Main.java │ ├── NetCatProtocolHandler.java │ └── package.html ├── Proxyserver ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── proxy │ ├── AbstractProxyIoHandler.java │ ├── ClientToProxyIoHandler.java │ ├── Main.java │ ├── ServerToProxyIoHandler.java │ └── package.html ├── README.md ├── ReverserServer ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── reverser │ ├── Main.java │ ├── ReverseProtocolHandler.java │ └── package.html ├── SumUpClient ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── sumup │ ├── Client.java │ └── ClientSessionHandler.java ├── SumUpCommon ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── sumup │ ├── codec │ ├── AbstractMessageDecoder.java │ ├── AbstractMessageEncoder.java │ ├── AddMessageDecoder.java │ ├── AddMessageEncoder.java │ ├── Constants.java │ ├── ResultMessageDecoder.java │ ├── ResultMessageEncoder.java │ ├── SumUpProtocolCodecFactory.java │ └── package.html │ └── message │ ├── AbstractMessage.java │ ├── AddMessage.java │ ├── ResultMessage.java │ └── package.html ├── SumUpServer ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── sumup │ ├── Server.java │ └── ServerSessionHandler.java ├── TCPClient ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── tcp │ └── perf │ └── TcpClient.java ├── TCPServer ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── tcp │ └── perf │ └── TcpServer.java ├── TennisBall ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── tennis │ ├── Main.java │ ├── TennisBall.java │ ├── TennisPlayer.java │ └── package.html ├── TimeServer ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── gettingstarted │ └── timeserver │ ├── MinaTimeServer.java │ └── TimeServerHandler.java ├── UDPClient ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── udp │ └── perf │ └── UdpClient.java ├── UDPServer ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ └── example │ └── udp │ └── perf │ └── UdpServer.java ├── android-client ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── neal │ │ └── minapush │ │ ├── activity │ │ └── MainActivity.java │ │ ├── applicaiton │ │ └── BaseApplication.java │ │ ├── push │ │ ├── ClientKeepAliveMessageFactoryImp.java │ │ ├── ClientPushMessage.java │ │ ├── ClientSessionHandler.java │ │ ├── Config.java │ │ ├── PushEventListener.java │ │ ├── PushManager.java │ │ ├── ServerKeepAliveMessageFactoryImp.java │ │ └── ServerPushMessage.java │ │ ├── service │ │ └── PushService.java │ │ └── util │ │ └── NetworkUtil.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ └── activity_main.xml │ └── values │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── common ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ └── java │ └── org │ └── apache │ └── mina │ ├── core │ ├── IoUtil.java │ ├── RuntimeIoException.java │ ├── buffer │ │ ├── AbstractIoBuffer.java │ │ ├── BufferDataException.java │ │ ├── CachedBufferAllocator.java │ │ ├── IoBuffer.java │ │ ├── IoBufferAllocator.java │ │ ├── IoBufferHexDumper.java │ │ ├── IoBufferWrapper.java │ │ └── SimpleBufferAllocator.java │ ├── file │ │ ├── DefaultFileRegion.java │ │ ├── FileRegion.java │ │ └── FilenameFileRegion.java │ ├── filterchain │ │ ├── DefaultIoFilterChain.java │ │ ├── DefaultIoFilterChainBuilder.java │ │ ├── IoFilter.java │ │ ├── IoFilterAdapter.java │ │ ├── IoFilterChain.java │ │ ├── IoFilterChainBuilder.java │ │ ├── IoFilterEvent.java │ │ └── IoFilterLifeCycleException.java │ ├── future │ │ ├── CloseFuture.java │ │ ├── CompositeIoFuture.java │ │ ├── ConnectFuture.java │ │ ├── DefaultCloseFuture.java │ │ ├── DefaultConnectFuture.java │ │ ├── DefaultIoFuture.java │ │ ├── DefaultReadFuture.java │ │ ├── DefaultWriteFuture.java │ │ ├── IoFuture.java │ │ ├── IoFutureListener.java │ │ ├── ReadFuture.java │ │ └── WriteFuture.java │ ├── polling │ │ ├── AbstractPollingIoAcceptor.java │ │ ├── AbstractPollingIoConnector.java │ │ ├── AbstractPollingIoProcessor.java │ │ └── package.html │ ├── service │ │ ├── AbstractIoAcceptor.java │ │ ├── AbstractIoConnector.java │ │ ├── AbstractIoService.java │ │ ├── DefaultTransportMetadata.java │ │ ├── IoAcceptor.java │ │ ├── IoConnector.java │ │ ├── IoHandler.java │ │ ├── IoHandlerAdapter.java │ │ ├── IoProcessor.java │ │ ├── IoService.java │ │ ├── IoServiceListener.java │ │ ├── IoServiceListenerSupport.java │ │ ├── IoServiceStatistics.java │ │ ├── SimpleIoProcessorPool.java │ │ └── TransportMetadata.java │ ├── session │ │ ├── AbstractIoSession.java │ │ ├── AbstractIoSessionConfig.java │ │ ├── AttributeKey.java │ │ ├── DefaultIoSessionDataStructureFactory.java │ │ ├── DummySession.java │ │ ├── ExpiringSessionRecycler.java │ │ ├── IdleStatus.java │ │ ├── IdleStatusChecker.java │ │ ├── IoEvent.java │ │ ├── IoEventType.java │ │ ├── IoSession.java │ │ ├── IoSessionAttributeMap.java │ │ ├── IoSessionConfig.java │ │ ├── IoSessionDataStructureFactory.java │ │ ├── IoSessionInitializationException.java │ │ ├── IoSessionInitializer.java │ │ ├── IoSessionRecycler.java │ │ ├── SessionState.java │ │ └── UnknownMessageTypeException.java │ └── write │ │ ├── DefaultWriteRequest.java │ │ ├── NothingWrittenException.java │ │ ├── WriteException.java │ │ ├── WriteRequest.java │ │ ├── WriteRequestQueue.java │ │ ├── WriteRequestWrapper.java │ │ ├── WriteTimeoutException.java │ │ └── WriteToClosedSessionException.java │ ├── filter │ ├── buffer │ │ ├── BufferedWriteFilter.java │ │ └── IoBufferLazyInitializer.java │ ├── codec │ │ ├── AbstractProtocolDecoderOutput.java │ │ ├── AbstractProtocolEncoderOutput.java │ │ ├── CumulativeProtocolDecoder.java │ │ ├── ProtocolCodecException.java │ │ ├── ProtocolCodecFactory.java │ │ ├── ProtocolCodecFilter.java │ │ ├── ProtocolCodecSession.java │ │ ├── ProtocolDecoder.java │ │ ├── ProtocolDecoderAdapter.java │ │ ├── ProtocolDecoderException.java │ │ ├── ProtocolDecoderOutput.java │ │ ├── ProtocolEncoder.java │ │ ├── ProtocolEncoderAdapter.java │ │ ├── ProtocolEncoderException.java │ │ ├── ProtocolEncoderOutput.java │ │ ├── RecoverableProtocolDecoderException.java │ │ ├── SynchronizedProtocolDecoder.java │ │ ├── SynchronizedProtocolEncoder.java │ │ ├── demux │ │ │ ├── DemuxingProtocolCodecFactory.java │ │ │ ├── DemuxingProtocolDecoder.java │ │ │ ├── DemuxingProtocolEncoder.java │ │ │ ├── MessageDecoder.java │ │ │ ├── MessageDecoderAdapter.java │ │ │ ├── MessageDecoderFactory.java │ │ │ ├── MessageDecoderResult.java │ │ │ ├── MessageEncoder.java │ │ │ ├── MessageEncoderFactory.java │ │ │ └── package.html │ │ ├── package.html │ │ ├── prefixedstring │ │ │ ├── PrefixedStringCodecFactory.java │ │ │ ├── PrefixedStringDecoder.java │ │ │ └── PrefixedStringEncoder.java │ │ ├── serialization │ │ │ ├── ObjectSerializationCodecFactory.java │ │ │ ├── ObjectSerializationDecoder.java │ │ │ ├── ObjectSerializationEncoder.java │ │ │ ├── ObjectSerializationInputStream.java │ │ │ ├── ObjectSerializationOutputStream.java │ │ │ └── package.html │ │ ├── statemachine │ │ │ ├── ConsumeToCrLfDecodingState.java │ │ │ ├── ConsumeToDynamicTerminatorDecodingState.java │ │ │ ├── ConsumeToEndOfSessionDecodingState.java │ │ │ ├── ConsumeToLinearWhitespaceDecodingState.java │ │ │ ├── ConsumeToTerminatorDecodingState.java │ │ │ ├── CrLfDecodingState.java │ │ │ ├── DecodingState.java │ │ │ ├── DecodingStateMachine.java │ │ │ ├── DecodingStateProtocolDecoder.java │ │ │ ├── FixedLengthDecodingState.java │ │ │ ├── IntegerDecodingState.java │ │ │ ├── LinearWhitespaceSkippingState.java │ │ │ ├── ShortIntegerDecodingState.java │ │ │ ├── SingleByteDecodingState.java │ │ │ └── SkippingState.java │ │ └── textline │ │ │ ├── LineDelimiter.java │ │ │ ├── TextLineCodecFactory.java │ │ │ ├── TextLineDecoder.java │ │ │ ├── TextLineEncoder.java │ │ │ └── package.html │ ├── errorgenerating │ │ ├── ErrorGeneratingFilter.java │ │ └── package.html │ ├── executor │ │ ├── DefaultIoEventSizeEstimator.java │ │ ├── ExecutorFilter.java │ │ ├── IoEventQueueHandler.java │ │ ├── IoEventQueueThrottle.java │ │ ├── IoEventSizeEstimator.java │ │ ├── OrderedThreadPoolExecutor.java │ │ ├── UnorderedThreadPoolExecutor.java │ │ ├── WriteRequestFilter.java │ │ └── package.html │ ├── firewall │ │ ├── BlacklistFilter.java │ │ ├── ConnectionThrottleFilter.java │ │ ├── Subnet.java │ │ └── package.html │ ├── keepalive │ │ ├── KeepAliveFilter.java │ │ ├── KeepAliveMessageFactory.java │ │ ├── KeepAliveRequestTimeoutException.java │ │ ├── KeepAliveRequestTimeoutHandler.java │ │ └── package.html │ ├── logging │ │ ├── LogLevel.java │ │ ├── LoggingFilter.java │ │ ├── MdcInjectionFilter.java │ │ └── package.html │ ├── ssl │ │ ├── BogusTrustManagerFactory.java │ │ ├── KeyStoreFactory.java │ │ ├── SslContextFactory.java │ │ ├── SslFilter.java │ │ ├── SslHandler.java │ │ └── package.html │ ├── statistic │ │ ├── ProfilerTimerFilter.java │ │ └── package.html │ ├── stream │ │ ├── AbstractStreamWriteFilter.java │ │ ├── FileRegionWriteFilter.java │ │ ├── StreamWriteFilter.java │ │ └── package.html │ └── util │ │ ├── CommonEventFilter.java │ │ ├── NoopFilter.java │ │ ├── ReferenceCountingFilter.java │ │ ├── SessionAttributeInitializingFilter.java │ │ ├── WriteRequestFilter.java │ │ └── package.html │ ├── handler │ ├── chain │ │ ├── ChainedIoHandler.java │ │ ├── IoHandlerChain.java │ │ ├── IoHandlerCommand.java │ │ └── package.html │ ├── demux │ │ ├── DemuxingIoHandler.java │ │ ├── ExceptionHandler.java │ │ ├── MessageHandler.java │ │ └── package.html │ ├── multiton │ │ ├── SingleSessionIoHandler.java │ │ ├── SingleSessionIoHandlerAdapter.java │ │ ├── SingleSessionIoHandlerDelegate.java │ │ ├── SingleSessionIoHandlerFactory.java │ │ └── package.html │ ├── package.html │ └── stream │ │ ├── IoSessionInputStream.java │ │ ├── IoSessionOutputStream.java │ │ └── StreamIoHandler.java │ ├── proxy │ ├── AbstractProxyIoHandler.java │ ├── AbstractProxyLogicHandler.java │ ├── ProxyAuthException.java │ ├── ProxyConnector.java │ ├── ProxyLogicHandler.java │ ├── event │ │ ├── IoSessionEvent.java │ │ ├── IoSessionEventQueue.java │ │ └── IoSessionEventType.java │ ├── filter │ │ ├── ProxyFilter.java │ │ └── ProxyHandshakeIoBuffer.java │ ├── handlers │ │ ├── ProxyRequest.java │ │ ├── http │ │ │ ├── AbstractAuthLogicHandler.java │ │ │ ├── AbstractHttpLogicHandler.java │ │ │ ├── HttpAuthenticationMethods.java │ │ │ ├── HttpProxyConstants.java │ │ │ ├── HttpProxyRequest.java │ │ │ ├── HttpProxyResponse.java │ │ │ ├── HttpSmartProxyHandler.java │ │ │ ├── basic │ │ │ │ ├── HttpBasicAuthLogicHandler.java │ │ │ │ └── HttpNoAuthLogicHandler.java │ │ │ ├── digest │ │ │ │ ├── DigestUtilities.java │ │ │ │ └── HttpDigestAuthLogicHandler.java │ │ │ └── ntlm │ │ │ │ ├── HttpNTLMAuthLogicHandler.java │ │ │ │ ├── NTLMConstants.java │ │ │ │ ├── NTLMResponses.java │ │ │ │ └── NTLMUtilities.java │ │ └── socks │ │ │ ├── AbstractSocksLogicHandler.java │ │ │ ├── Socks4LogicHandler.java │ │ │ ├── Socks5LogicHandler.java │ │ │ ├── SocksProxyConstants.java │ │ │ └── SocksProxyRequest.java │ ├── session │ │ ├── ProxyIoSession.java │ │ └── ProxyIoSessionInitializer.java │ └── utils │ │ ├── ByteUtilities.java │ │ ├── IoBufferDecoder.java │ │ └── StringUtilities.java │ ├── test │ ├── ClientKeepAliveMessageFactoryImp.java │ ├── ClientSessionHandler.java │ ├── KeepAliveMessageFactoryImp.java │ ├── LongTcpServer.java │ ├── ServerKeepAliveMessageFactoryImp.java │ └── ServerSessionHandler.java │ ├── transport │ ├── socket │ │ ├── AbstractDatagramSessionConfig.java │ │ ├── AbstractSocketSessionConfig.java │ │ ├── DatagramAcceptor.java │ │ ├── DatagramConnector.java │ │ ├── DatagramSessionConfig.java │ │ ├── DefaultDatagramSessionConfig.java │ │ ├── DefaultSocketSessionConfig.java │ │ ├── SocketAcceptor.java │ │ ├── SocketConnector.java │ │ ├── SocketSessionConfig.java │ │ └── nio │ │ │ ├── NioDatagramAcceptor.java │ │ │ ├── NioDatagramConnector.java │ │ │ ├── NioDatagramSession.java │ │ │ ├── NioDatagramSessionConfig.java │ │ │ ├── NioProcessor.java │ │ │ ├── NioSession.java │ │ │ ├── NioSocketAcceptor.java │ │ │ ├── NioSocketConnector.java │ │ │ ├── NioSocketSession.java │ │ │ └── package.html │ └── vmpipe │ │ ├── DefaultVmPipeSessionConfig.java │ │ ├── VmPipe.java │ │ ├── VmPipeAcceptor.java │ │ ├── VmPipeAddress.java │ │ ├── VmPipeConnector.java │ │ ├── VmPipeFilterChain.java │ │ ├── VmPipeSession.java │ │ ├── VmPipeSessionConfig.java │ │ └── package.html │ └── util │ ├── AvailablePortFinder.java │ ├── Base64.java │ ├── CircularQueue.java │ ├── ConcurrentHashSet.java │ ├── CopyOnWriteMap.java │ ├── DefaultExceptionMonitor.java │ ├── ExceptionMonitor.java │ ├── ExpirationListener.java │ ├── ExpiringMap.java │ ├── IdentityHashSet.java │ ├── LazyInitializedCacheMap.java │ ├── LazyInitializer.java │ ├── Log4jXmlFormatter.java │ ├── MapBackedSet.java │ ├── NamePreservingRunnable.java │ ├── SynchronizedQueue.java │ ├── Transform.java │ ├── byteaccess │ ├── AbstractByteArray.java │ ├── BufferByteArray.java │ ├── ByteArray.java │ ├── ByteArrayFactory.java │ ├── ByteArrayList.java │ ├── ByteArrayPool.java │ ├── CompositeByteArray.java │ ├── CompositeByteArrayRelativeBase.java │ ├── CompositeByteArrayRelativeReader.java │ ├── CompositeByteArrayRelativeWriter.java │ ├── IoAbsoluteReader.java │ ├── IoAbsoluteWriter.java │ ├── IoRelativeReader.java │ ├── IoRelativeWriter.java │ └── SimpleByteArrayFactory.java │ └── package.html ├── gradle.properties ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### NetBeans template 3 | nbproject/private/ 4 | build/ 5 | nbbuild/ 6 | dist/ 7 | nbdist/ 8 | nbactions.xml 9 | nb-configuration.xml 10 | 11 | # Mac OS X Garbage 12 | .DS_Store 13 | Thumbs.db 14 | 15 | .idea/ 16 | 17 | ### Android Studio 18 | /jniLibs 19 | mobile/mobile.iml 20 | mobile/mobile.iml 21 | tv/tv.iml 22 | app/app.iml 23 | app/*.iml 24 | *.iml 25 | mobile/*.iml 26 | tv/*.iml 27 | .idea/workspace.xml 28 | .idea/libraries 29 | .idea/ 30 | .idea 31 | /build 32 | /captures 33 | ### Android template 34 | # Built application files 35 | *.apk 36 | *.ap_ 37 | /build 38 | /captures 39 | # Files for the Dalvik VM 40 | *.dex 41 | 42 | # Java class files 43 | *.class 44 | 45 | # Generated files 46 | bin/ 47 | gen/ 48 | 49 | # Gradle files 50 | .gradle/ 51 | 52 | # Local configuration file (sdk path, etc) 53 | local.properties 54 | 55 | # Proguard folder generated by Eclipse 56 | proguard/ 57 | 58 | # Log Files 59 | *.log 60 | 61 | 62 | ### Java template 63 | *.class 64 | 65 | # Mobile Tools for Java (J2ME) 66 | .mtj.tmp/ 67 | 68 | # Package Files # 69 | *.jar 70 | *.war 71 | *.ear 72 | 73 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 74 | hs_err_pid* 75 | 76 | 77 | ### Eclipse template 78 | *.pydevproject 79 | .metadata 80 | .gradle 81 | bin/ 82 | tmp/ 83 | *.tmp 84 | *.bak 85 | *.swp 86 | *~.nib 87 | .settings/ 88 | .loadpath 89 | /build 90 | /captures 91 | # External tool builders 92 | .externalToolBuilders/ 93 | 94 | # Locally stored "Eclipse launch configurations" 95 | *.launch 96 | 97 | # CDT-specific 98 | .cproject 99 | 100 | # PDT-specific 101 | .buildpath 102 | 103 | # sbteclipse plugin 104 | .target 105 | 106 | # TeXlipse plugin 107 | .texlipse 108 | 109 | # Android Studio 110 | *.iml 111 | 112 | # Keep external libs 113 | !app/libs/*.jar 114 | 115 | # script output 116 | check-dpi.txt* 117 | -------------------------------------------------------------------------------- /001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sddyljsx/tcp-long-connection-based-on-apache-mina/c82332d7e7543ff9d785bb40ee09c1b22846ffbd/001.png -------------------------------------------------------------------------------- /002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sddyljsx/tcp-long-connection-based-on-apache-mina/c82332d7e7543ff9d785bb40ee09c1b22846ffbd/002.png -------------------------------------------------------------------------------- /003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sddyljsx/tcp-long-connection-based-on-apache-mina/c82332d7e7543ff9d785bb40ee09c1b22846ffbd/003.png -------------------------------------------------------------------------------- /EchoServer/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /EchoServer/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Users\Neo\Documents\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /EchoServer/src/main/java/org/apache/mina/example/echoserver/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 |
20 | 21 | 22 | Echo server which demonstates low-level I/O layer and SSL support. 23 | 24 | 25 | -------------------------------------------------------------------------------- /EchoServer/src/main/java/org/apache/mina/example/echoserver/ssl/package.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | 22 | SSL support classes. 23 | 24 | 25 | -------------------------------------------------------------------------------- /HaikuValidationServer/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /HaikuValidationServer/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Users\Neo\Documents\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /HaikuValidationServer/src/main/java/org/apache/mina/example/haiku/Haiku.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.mina.example.haiku; 20 | 21 | import java.util.Arrays; 22 | 23 | /** 24 | * @author Apache MINA Project 25 | */ 26 | public class Haiku { 27 | private final String[] phrases; 28 | 29 | public Haiku(String... lines) { 30 | this.phrases = lines; 31 | if (null == lines || lines.length != 3) { 32 | throw new IllegalArgumentException("Must pass in 3 phrases of text"); 33 | } 34 | } 35 | 36 | public String[] getPhrases() { 37 | return phrases; 38 | } 39 | 40 | @Override 41 | public boolean equals(Object o) { 42 | if (this == o) 43 | return true; 44 | if (o == null || getClass() != o.getClass()) 45 | return false; 46 | 47 | Haiku haiku = (Haiku) o; 48 | 49 | return Arrays.equals(phrases, haiku.phrases); 50 | } 51 | 52 | @Override 53 | public int hashCode() { 54 | return Arrays.hashCode(phrases); 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return Arrays.toString(phrases); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /HaikuValidationServer/src/main/java/org/apache/mina/example/haiku/HaikuValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.mina.example.haiku; 20 | 21 | /** 22 | * @author Apache MINA Project 23 | */ 24 | public class HaikuValidator { 25 | private static final int[] SYLLABLE_COUNTS = { 5, 7, 5 }; 26 | 27 | public void validate(Haiku haiku) throws InvalidHaikuException { 28 | String[] phrases = haiku.getPhrases(); 29 | 30 | for (int i = 0; i < phrases.length; i++) { 31 | String phrase = phrases[i]; 32 | int count = PhraseUtilities.countSyllablesInPhrase(phrase); 33 | 34 | if (count != SYLLABLE_COUNTS[i]) { 35 | throw new InvalidHaikuException(i + 1, phrase, count, 36 | SYLLABLE_COUNTS[i]); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /HaikuValidationServer/src/main/java/org/apache/mina/example/haiku/HaikuValidatorIoHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.mina.example.haiku; 20 | 21 | import org.apache.mina.core.service.IoHandlerAdapter; 22 | import org.apache.mina.core.session.IoSession; 23 | 24 | /** 25 | * @author Apache MINA Project 26 | */ 27 | 28 | public class HaikuValidatorIoHandler extends IoHandlerAdapter { 29 | 30 | private final HaikuValidator validator = new HaikuValidator(); 31 | 32 | @Override 33 | public void messageReceived(IoSession session, Object message) 34 | throws Exception { 35 | Haiku haiku = (Haiku) message; 36 | 37 | try { 38 | validator.validate(haiku); 39 | session.write("HAIKU!"); 40 | } catch (InvalidHaikuException e) { 41 | session.write("NOT A HAIKU: " + e.getMessage()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /HaikuValidationServer/src/main/java/org/apache/mina/example/haiku/InvalidHaikuException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.mina.example.haiku; 20 | 21 | /** 22 | * @author Apache MINA Project 23 | */ 24 | public class InvalidHaikuException extends Exception { 25 | private static final long serialVersionUID = 34877739006797894L; 26 | 27 | private final int position; 28 | 29 | private final String phrase; 30 | 31 | private final int syllableCount; 32 | 33 | private final int expectedSyllableCount; 34 | 35 | public InvalidHaikuException(int position, String phrase, 36 | int syllableCount, int expectedSyllableCount) { 37 | super("phrase " + position + ", '" + phrase + "' had " + syllableCount 38 | + " syllables, not " + expectedSyllableCount); 39 | 40 | this.position = position; 41 | this.phrase = phrase; 42 | this.syllableCount = syllableCount; 43 | this.expectedSyllableCount = expectedSyllableCount; 44 | } 45 | 46 | public int getExpectedSyllableCount() { 47 | return expectedSyllableCount; 48 | } 49 | 50 | public String getPhrase() { 51 | return phrase; 52 | } 53 | 54 | public int getSyllableCount() { 55 | return syllableCount; 56 | } 57 | 58 | public int getPhrasePosition() { 59 | return position; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /HaikuValidationServer/src/main/java/org/apache/mina/example/haiku/ToHaikuIoFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.mina.example.haiku; 20 | 21 | import org.apache.mina.core.filterchain.IoFilterAdapter; 22 | import org.apache.mina.core.session.IoSession; 23 | 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | /** 28 | * @author Apache MINA Project 29 | */ 30 | public class ToHaikuIoFilter extends IoFilterAdapter { 31 | 32 | @SuppressWarnings( { "unchecked" }) 33 | @Override 34 | public void messageReceived(NextFilter nextFilter, IoSession session, 35 | Object message) throws Exception { 36 | Listcat
command) which demonstates low-level I/O layer.
23 |
24 |
25 |