4.2.3 限制每个客户端的时间.......................................................................................92
4.3 多接收
者..........................................................................................................................94
4.3.1 广播.......................................................................................................................
94
4.3.2 多播.......................................................................................................................
95
4.4 控
制默认行为................................................................................................................100
4.4.1 Keep-Alive...........................................................................................................
100
4.4.2 发送和接收缓存区的大小.................................................................................101
4.4.3 超时.....................................................................................................................
101
4.4.4 地址
重用.............................................................................................................102
4.4.5 消除
缓冲延迟.....................................................................................................102
4.4.6 紧急
数据.............................................................................................................103
4.4.7 关闭
后停留.........................................................................................................103
4.4.8 广播
许可.............................................................................................................103
4.4.9 通信
等级.............................................................................................................104
4.4.10 基于
性能的协议选择.......................................................................................104
4.5 关闭连
接........................................................................................................................104
4.6 Applets ...........................................................................................................................
111
4.7 结束................................................................................................................................112
4.8 练习................................................................................................................................
112
第 5 章 NIO.................................................................................................................................
112
5.1 为
什么需要NIO? ........................................................................................................113
5.2 与Buffer一起使用
Channel..........................................................................................115
5.3 Selector...........................................................................................................................
118
5.4 Buffer详解 .....................................................................................................................125
5.4.1 Buffer索引
...........................................................................................................125
5.4.2 创建Bu
ffer..........................................................................................................126
5.4.3 存
储和接收数据.................................................................................................128
5.4.4 准备Bu
ffer:clear(),flip(),和rewind()........................................................130
5.4.5 压缩Bu
ffer中的数据..........................................................................................132
5.4.6 Buffer透视:
duplicate(),slice()等 ..................................................................134
5.4.7 字符
编码.............................................................................................................136
5.5 流(
TCP)信道详解....................................................................................................136
5.6 Selector详解...................................................................................................................
139
5.6.1 在信
道中注册.....................................................................................................139
5.6.2 选
取和识别准备就绪的信道.............................................................................141
5.6.3 信道
附件.............................................................................................................143
5.6.4 Selector小结........................................................................................................
144
5.7 数据报
(UDP)信道 ...................................................................................................144
5.8 练习................................................................................................................................1
49
1. 使用定长
的写缓冲区改写TCPEchoClientNonblocking.java。 ....................................149
2.使用
Buffer和DatagramChannel编写一个回显客户端。 ................................................149
第 6 章 深入
剖析 ........................................................................................................................149
6.1 缓冲和TCP....................................................................................................................
152
6.2 死锁风
险........................................................................................................................155
鸿鹄书院 http://book.hh010.com
鸿鹄论坛 http://bbs.hh010.com