狠狠撸

狠狠撸Share a Scribd company logo
初窥 Java 网络 IO

          DigitalSonic
             2011-10
同步?异步?阻塞?非阻塞?




UNIX? Network Programming Volume 1, Third Edition: The Sockets Networking
IO in Java
●   JDK 1.4 —— NIO
    ●   我们有了 Non-Blocking IO
●   JDK 1.7—— NIO2
    ●   我们有了 Asynchronous IO
    ●   Linux 下通过 epoll 模拟实现
    ●   Windows 下通过 IOCP 实现
传统 Socket 服务器实现方式
●   用 ServerSocket 绑定某个端口
●   循环 accept
    ●   开启一个新线程处理 Socket
    ●   处理完毕后关闭 Socket
NIO – How To
●   非阻塞 ServerSocketChannel 绑定端口
●   注册选择器
●   循环 select
    ●   处理 select 的结果 key
    ●   处理完毕移除 key
NIO 范例
NIO 范例
AIO – How To
●   配置线程池
●   AsynchronousServerSocketChannel 绑定端口
●   accept
    ●   返回 Future 做进一步处理
    ●   设定 CompletionHandler ,在其中做进一步处理
AIO 范例
AIO 范例
AIO 范例
AIO 范例




Start listening on 8888.
sun.nio.ch.UnixAsynchronousServerSocketChannelImpl[/0:0:0:0:0:0:0:0:8888]
AsynchronousSocketChannel Accepted!sun.nio.ch.UnixAsynchronousSocketChannelImpl
[connected local=/0:0:0:0:0:0:0:1:8888 remote=/0:0:0:0:0:0:0:1:48716]
sun.nio.ch.UnixAsynchronousSocketChannelImpl
[connected local=/0:0:0:0:0:0:0:1:8888 remote=/0:0:0:0:0:0:0:1:48716] said: abc
sun.nio.ch.UnixAsynchronousSocketChannelImpl
[connected local=/0:0:0:0:0:0:0:1:8888 remote=/0:0:0:0:0:0:0:1:48716] said: exit

More Related Content

What's hot (20)

Proxmox: 建立自己的虛擬主機
Proxmox: 建立自己的虛擬主機Proxmox: 建立自己的虛擬主機
Proxmox: 建立自己的虛擬主機
維泰 蔡
?
狈辞诲别.箩蝉长连接开发实践
狈辞诲别.箩蝉长连接开发实践狈辞诲别.箩蝉长连接开发实践
狈辞诲别.箩蝉长连接开发实践
longhao
?
SDN ryu 專題安裝
SDN ryu 專題安裝SDN ryu 專題安裝
SDN ryu 專題安裝
承樺 董
?
Node js q-con
Node js q-conNode js q-con
Node js q-con
q3boy
?
Node.js 淺談socket.io
Node.js   淺談socket.ioNode.js   淺談socket.io
Node.js 淺談socket.io
Simon Su
?
twMVC#43 YARP
twMVC#43 YARPtwMVC#43 YARP
twMVC#43 YARP
twMVC
?
async io frame
async io frameasync io frame
async io frame
rfyiamcool
?
SITCON 2021 想上網?大展 l3 路由魔法吧!
SITCON 2021 想上網?大展 l3 路由魔法吧!SITCON 2021 想上網?大展 l3 路由魔法吧!
SITCON 2021 想上網?大展 l3 路由魔法吧!
Tsung-Yi Yu
?
NodeJS快速服务端开发 朝沐金风 Shanghai
NodeJS快速服务端开发 朝沐金风 ShanghaiNodeJS快速服务端开发 朝沐金风 Shanghai
NodeJS快速服务端开发 朝沐金风 Shanghai
Jackson Tian
?
基于罢辞谤苍补诲辞后端系统架构暨最佳实践
基于罢辞谤苍补诲辞后端系统架构暨最佳实践基于罢辞谤苍补诲辞后端系统架构暨最佳实践
基于罢辞谤苍补诲辞后端系统架构暨最佳实践
ZY Zhang
?
OpenStack Neutron Introduction
OpenStack Neutron IntroductionOpenStack Neutron Introduction
OpenStack Neutron Introduction
Liang Bo
?
lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用
hugo
?
Container Security
Container SecurityContainer Security
Container Security
LinuxCon ContainerCon CloudOpen China
?
2021/06/07 CSST
2021/06/07 CSST2021/06/07 CSST
2021/06/07 CSST
Tsung-Yi Yu
?
笔贬笔/狈辞诲别闯厂/搁别诲颈蝉项目实战
笔贬笔/狈辞诲别闯厂/搁别诲颈蝉项目实战笔贬笔/狈辞诲别闯厂/搁别诲颈蝉项目实战
笔贬笔/狈辞诲别闯厂/搁别诲颈蝉项目实战
Sun Zephyr
?
twMVC#42 讓我們用一種方式來開發吧
twMVC#42 讓我們用一種方式來開發吧twMVC#42 讓我們用一種方式來開發吧
twMVC#42 讓我們用一種方式來開發吧
twMVC
?
twMVC#43 Visual Studio 2022 新功能拆解
twMVC#43 Visual Studio 2022 新功能拆解twMVC#43 Visual Studio 2022 新功能拆解
twMVC#43 Visual Studio 2022 新功能拆解
twMVC
?
滨辞罢开发平台狈辞诲别惭颁鲍
滨辞罢开发平台狈辞诲别惭颁鲍滨辞罢开发平台狈辞诲别惭颁鲍
滨辞罢开发平台狈辞诲别惭颁鲍
承翰 蔡
?
Node.js從無到有 基本課程
Node.js從無到有 基本課程Node.js從無到有 基本課程
Node.js從無到有 基本課程
Simon Su
?
[LaravelConf Taiwan 2018] 如何正確佈署 Laravel 專案
[LaravelConf Taiwan 2018] 如何正確佈署 Laravel 專案[LaravelConf Taiwan 2018] 如何正確佈署 Laravel 專案
[LaravelConf Taiwan 2018] 如何正確佈署 Laravel 專案
LaravelConfTaiwan
?
Proxmox: 建立自己的虛擬主機
Proxmox: 建立自己的虛擬主機Proxmox: 建立自己的虛擬主機
Proxmox: 建立自己的虛擬主機
維泰 蔡
?
狈辞诲别.箩蝉长连接开发实践
狈辞诲别.箩蝉长连接开发实践狈辞诲别.箩蝉长连接开发实践
狈辞诲别.箩蝉长连接开发实践
longhao
?
SDN ryu 專題安裝
SDN ryu 專題安裝SDN ryu 專題安裝
SDN ryu 專題安裝
承樺 董
?
Node js q-con
Node js q-conNode js q-con
Node js q-con
q3boy
?
Node.js 淺談socket.io
Node.js   淺談socket.ioNode.js   淺談socket.io
Node.js 淺談socket.io
Simon Su
?
twMVC#43 YARP
twMVC#43 YARPtwMVC#43 YARP
twMVC#43 YARP
twMVC
?
SITCON 2021 想上網?大展 l3 路由魔法吧!
SITCON 2021 想上網?大展 l3 路由魔法吧!SITCON 2021 想上網?大展 l3 路由魔法吧!
SITCON 2021 想上網?大展 l3 路由魔法吧!
Tsung-Yi Yu
?
NodeJS快速服务端开发 朝沐金风 Shanghai
NodeJS快速服务端开发 朝沐金风 ShanghaiNodeJS快速服务端开发 朝沐金风 Shanghai
NodeJS快速服务端开发 朝沐金风 Shanghai
Jackson Tian
?
基于罢辞谤苍补诲辞后端系统架构暨最佳实践
基于罢辞谤苍补诲辞后端系统架构暨最佳实践基于罢辞谤苍补诲辞后端系统架构暨最佳实践
基于罢辞谤苍补诲辞后端系统架构暨最佳实践
ZY Zhang
?
OpenStack Neutron Introduction
OpenStack Neutron IntroductionOpenStack Neutron Introduction
OpenStack Neutron Introduction
Liang Bo
?
lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用lua & ngx_lua 的介绍与应用
lua & ngx_lua 的介绍与应用
hugo
?
笔贬笔/狈辞诲别闯厂/搁别诲颈蝉项目实战
笔贬笔/狈辞诲别闯厂/搁别诲颈蝉项目实战笔贬笔/狈辞诲别闯厂/搁别诲颈蝉项目实战
笔贬笔/狈辞诲别闯厂/搁别诲颈蝉项目实战
Sun Zephyr
?
twMVC#42 讓我們用一種方式來開發吧
twMVC#42 讓我們用一種方式來開發吧twMVC#42 讓我們用一種方式來開發吧
twMVC#42 讓我們用一種方式來開發吧
twMVC
?
twMVC#43 Visual Studio 2022 新功能拆解
twMVC#43 Visual Studio 2022 新功能拆解twMVC#43 Visual Studio 2022 新功能拆解
twMVC#43 Visual Studio 2022 新功能拆解
twMVC
?
滨辞罢开发平台狈辞诲别惭颁鲍
滨辞罢开发平台狈辞诲别惭颁鲍滨辞罢开发平台狈辞诲别惭颁鲍
滨辞罢开发平台狈辞诲别惭颁鲍
承翰 蔡
?
Node.js從無到有 基本課程
Node.js從無到有 基本課程Node.js從無到有 基本課程
Node.js從無到有 基本課程
Simon Su
?
[LaravelConf Taiwan 2018] 如何正確佈署 Laravel 專案
[LaravelConf Taiwan 2018] 如何正確佈署 Laravel 專案[LaravelConf Taiwan 2018] 如何正確佈署 Laravel 專案
[LaravelConf Taiwan 2018] 如何正確佈署 Laravel 專案
LaravelConfTaiwan
?

Viewers also liked (20)

实战HotSpot JVM GC
实战HotSpot JVM GC实战HotSpot JVM GC
实战HotSpot JVM GC
digitalsonic
?
RESTful Web Services with Spring MVC
RESTful Web Services with Spring MVCRESTful Web Services with Spring MVC
RESTful Web Services with Spring MVC
digitalsonic
?
Spring MVC - Web Forms
Spring MVC  - Web FormsSpring MVC  - Web Forms
Spring MVC - Web Forms
Ilio Catallo
?
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web Applications
Sam Brannen
?
Struts 2 + Spring
Struts 2 + SpringStruts 2 + Spring
Struts 2 + Spring
Bryan Hsueh
?
Boostrap - Start Up
Boostrap - Start UpBoostrap - Start Up
Boostrap - Start Up
Gabriel Darwin Lopez
?
Authentication and Authorization
Authentication and AuthorizationAuthentication and Authorization
Authentication and Authorization
TechMaster Vietnam
?
Node.js c?n b?n
Node.js c?n b?nNode.js c?n b?n
Node.js c?n b?n
TechMaster Vietnam
?
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
IndicThreads
?
Spring MVC - The Basics
Spring MVC -  The BasicsSpring MVC -  The Basics
Spring MVC - The Basics
Ilio Catallo
?
Front end architectureFront end architecture
Front end architecture
Rafael Salerno de Oliveira
?
Desenvolvimento Front end (AngularJS e Bootstrap)Desenvolvimento Front end (AngularJS e Bootstrap)
Desenvolvimento Front end (AngularJS e Bootstrap)
Julian Cesar
?
JSP Standard Tag Library
JSP Standard Tag LibraryJSP Standard Tag Library
JSP Standard Tag Library
Ilio Catallo
?
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
Toshiaki Maki
?
C++ Standard Template Library
C++ Standard Template LibraryC++ Standard Template Library
C++ Standard Template Library
Ilio Catallo
?
Tools For jQuery Application Architecture (Extended 狠狠撸s)
Tools For jQuery Application Architecture (Extended 狠狠撸s)Tools For jQuery Application Architecture (Extended 狠狠撸s)
Tools For jQuery Application Architecture (Extended 狠狠撸s)
Addy Osmani
?
Spring IO 2016 - Spring Cloud Microservices, a journey inside a financial entity
Spring IO 2016 - Spring Cloud Microservices, a journey inside a financial entitySpring IO 2016 - Spring Cloud Microservices, a journey inside a financial entity
Spring IO 2016 - Spring Cloud Microservices, a journey inside a financial entity
Toni Jara
?
Modern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsModern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design Patterns
Volodymyr Voytyshyn
?
Reputation matters - what's yours?
Reputation matters - what's yours?Reputation matters - what's yours?
Reputation matters - what's yours?
Sara Shailer
?
Hy solution??(4)?????????
Hy solution??(4)?????????Hy solution??(4)?????????
Hy solution??(4)?????????
valuasset
?
RESTful Web Services with Spring MVC
RESTful Web Services with Spring MVCRESTful Web Services with Spring MVC
RESTful Web Services with Spring MVC
digitalsonic
?
Spring MVC - Web Forms
Spring MVC  - Web FormsSpring MVC  - Web Forms
Spring MVC - Web Forms
Ilio Catallo
?
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web Applications
Sam Brannen
?
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
IndicThreads
?
Spring MVC - The Basics
Spring MVC -  The BasicsSpring MVC -  The Basics
Spring MVC - The Basics
Ilio Catallo
?
Front end architectureFront end architecture
Front end architecture
Rafael Salerno de Oliveira
?
Desenvolvimento Front end (AngularJS e Bootstrap)Desenvolvimento Front end (AngularJS e Bootstrap)
Desenvolvimento Front end (AngularJS e Bootstrap)
Julian Cesar
?
JSP Standard Tag Library
JSP Standard Tag LibraryJSP Standard Tag Library
JSP Standard Tag Library
Ilio Catallo
?
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
Toshiaki Maki
?
C++ Standard Template Library
C++ Standard Template LibraryC++ Standard Template Library
C++ Standard Template Library
Ilio Catallo
?
Tools For jQuery Application Architecture (Extended 狠狠撸s)
Tools For jQuery Application Architecture (Extended 狠狠撸s)Tools For jQuery Application Architecture (Extended 狠狠撸s)
Tools For jQuery Application Architecture (Extended 狠狠撸s)
Addy Osmani
?
Spring IO 2016 - Spring Cloud Microservices, a journey inside a financial entity
Spring IO 2016 - Spring Cloud Microservices, a journey inside a financial entitySpring IO 2016 - Spring Cloud Microservices, a journey inside a financial entity
Spring IO 2016 - Spring Cloud Microservices, a journey inside a financial entity
Toni Jara
?
Modern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsModern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design Patterns
Volodymyr Voytyshyn
?
Reputation matters - what's yours?
Reputation matters - what's yours?Reputation matters - what's yours?
Reputation matters - what's yours?
Sara Shailer
?
Hy solution??(4)?????????
Hy solution??(4)?????????Hy solution??(4)?????????
Hy solution??(4)?????????
valuasset
?

Similar to 初窥闯补惫补网络滨翱 (20)

Infiniflash benchmark
Infiniflash benchmarkInfiniflash benchmark
Infiniflash benchmark
Louis liu
?
Introduction of netty
Introduction of nettyIntroduction of netty
Introduction of netty
Bing Luo
?
Head first in xmemcached yanf4j
Head first in xmemcached yanf4jHead first in xmemcached yanf4j
Head first in xmemcached yanf4j
wavefly
?
厂丑辞飞颈苍苍辞诲产蝉迟补迟耻蝉公开
厂丑辞飞颈苍苍辞诲产蝉迟补迟耻蝉公开厂丑辞飞颈苍苍辞诲产蝉迟补迟耻蝉公开
厂丑辞飞颈苍苍辞诲产蝉迟补迟耻蝉公开
longxibendi
?
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
YingSiang Geng
?
高级服务器设计和实现1
高级服务器设计和实现1高级服务器设计和实现1
高级服务器设计和实现1
Feng Yu
?
Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得
roboard
?
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
Kenny (netman)
?
尝惫蝉在大规模网络环境下的应用辫耻办辞苍驳
尝惫蝉在大规模网络环境下的应用辫耻办辞苍驳尝惫蝉在大规模网络环境下的应用辫耻办辞苍驳
尝惫蝉在大规模网络环境下的应用辫耻办辞苍驳
Michael Zhang
?
2011 06-12-lamp-mysql-顾春江
2011 06-12-lamp-mysql-顾春江2011 06-12-lamp-mysql-顾春江
2011 06-12-lamp-mysql-顾春江
thinkinlamp
?
2011 06-12-lamp-mysql
2011 06-12-lamp-mysql2011 06-12-lamp-mysql
2011 06-12-lamp-mysql
pwesh
?
Nodejs & NAE
Nodejs & NAENodejs & NAE
Nodejs & NAE
q3boy
?
My sql 5.5 innodb xtradb 性能诊断与优化
My sql 5.5 innodb xtradb 性能诊断与优化My sql 5.5 innodb xtradb 性能诊断与优化
My sql 5.5 innodb xtradb 性能诊断与优化
YUCHENG HU
?
闯补惫补线上应用问题排查方法和工具(空望)
闯补惫补线上应用问题排查方法和工具(空望)闯补惫补线上应用问题排查方法和工具(空望)
闯补惫补线上应用问题排查方法和工具(空望)
ykdsg
?
服务器基准测试-叶金荣蔼颁驰翱鲍-20121130
服务器基准测试-叶金荣蔼颁驰翱鲍-20121130服务器基准测试-叶金荣蔼颁驰翱鲍-20121130
服务器基准测试-叶金荣蔼颁驰翱鲍-20121130
Jinrong Ye
?
Sth About SSD
Sth About SSDSth About SSD
Sth About SSD
XueZhang Wu
?
Oracle Security 101
Oracle Security 101Oracle Security 101
Oracle Security 101
Dahui Feng
?
Infiniflash benchmark
Infiniflash benchmarkInfiniflash benchmark
Infiniflash benchmark
Louis liu
?
Introduction of netty
Introduction of nettyIntroduction of netty
Introduction of netty
Bing Luo
?
Head first in xmemcached yanf4j
Head first in xmemcached yanf4jHead first in xmemcached yanf4j
Head first in xmemcached yanf4j
wavefly
?
厂丑辞飞颈苍苍辞诲产蝉迟补迟耻蝉公开
厂丑辞飞颈苍苍辞诲产蝉迟补迟耻蝉公开厂丑辞飞颈苍苍辞诲产蝉迟补迟耻蝉公开
厂丑辞飞颈苍苍辞诲产蝉迟补迟耻蝉公开
longxibendi
?
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
YingSiang Geng
?
高级服务器设计和实现1
高级服务器设计和实现1高级服务器设计和实现1
高级服务器设计和实现1
Feng Yu
?
Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得
roboard
?
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
Kenny (netman)
?
尝惫蝉在大规模网络环境下的应用辫耻办辞苍驳
尝惫蝉在大规模网络环境下的应用辫耻办辞苍驳尝惫蝉在大规模网络环境下的应用辫耻办辞苍驳
尝惫蝉在大规模网络环境下的应用辫耻办辞苍驳
Michael Zhang
?
2011 06-12-lamp-mysql-顾春江
2011 06-12-lamp-mysql-顾春江2011 06-12-lamp-mysql-顾春江
2011 06-12-lamp-mysql-顾春江
thinkinlamp
?
2011 06-12-lamp-mysql
2011 06-12-lamp-mysql2011 06-12-lamp-mysql
2011 06-12-lamp-mysql
pwesh
?
Nodejs & NAE
Nodejs & NAENodejs & NAE
Nodejs & NAE
q3boy
?
My sql 5.5 innodb xtradb 性能诊断与优化
My sql 5.5 innodb xtradb 性能诊断与优化My sql 5.5 innodb xtradb 性能诊断与优化
My sql 5.5 innodb xtradb 性能诊断与优化
YUCHENG HU
?
闯补惫补线上应用问题排查方法和工具(空望)
闯补惫补线上应用问题排查方法和工具(空望)闯补惫补线上应用问题排查方法和工具(空望)
闯补惫补线上应用问题排查方法和工具(空望)
ykdsg
?
服务器基准测试-叶金荣蔼颁驰翱鲍-20121130
服务器基准测试-叶金荣蔼颁驰翱鲍-20121130服务器基准测试-叶金荣蔼颁驰翱鲍-20121130
服务器基准测试-叶金荣蔼颁驰翱鲍-20121130
Jinrong Ye
?
Oracle Security 101
Oracle Security 101Oracle Security 101
Oracle Security 101
Dahui Feng
?

初窥闯补惫补网络滨翱

  • 1. 初窥 Java 网络 IO DigitalSonic 2011-10
  • 2. 同步?异步?阻塞?非阻塞? UNIX? Network Programming Volume 1, Third Edition: The Sockets Networking
  • 3. IO in Java ● JDK 1.4 —— NIO ● 我们有了 Non-Blocking IO ● JDK 1.7—— NIO2 ● 我们有了 Asynchronous IO ● Linux 下通过 epoll 模拟实现 ● Windows 下通过 IOCP 实现
  • 4. 传统 Socket 服务器实现方式 ● 用 ServerSocket 绑定某个端口 ● 循环 accept ● 开启一个新线程处理 Socket ● 处理完毕后关闭 Socket
  • 5. NIO – How To ● 非阻塞 ServerSocketChannel 绑定端口 ● 注册选择器 ● 循环 select ● 处理 select 的结果 key ● 处理完毕移除 key
  • 8. AIO – How To ● 配置线程池 ● AsynchronousServerSocketChannel 绑定端口 ● accept ● 返回 Future 做进一步处理 ● 设定 CompletionHandler ,在其中做进一步处理
  • 12. AIO 范例 Start listening on 8888. sun.nio.ch.UnixAsynchronousServerSocketChannelImpl[/0:0:0:0:0:0:0:0:8888] AsynchronousSocketChannel Accepted!sun.nio.ch.UnixAsynchronousSocketChannelImpl [connected local=/0:0:0:0:0:0:0:1:8888 remote=/0:0:0:0:0:0:0:1:48716] sun.nio.ch.UnixAsynchronousSocketChannelImpl [connected local=/0:0:0:0:0:0:0:1:8888 remote=/0:0:0:0:0:0:0:1:48716] said: abc sun.nio.ch.UnixAsynchronousSocketChannelImpl [connected local=/0:0:0:0:0:0:0:1:8888 remote=/0:0:0:0:0:0:0:1:48716] said: exit