没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
MEAP Edition
Manning Early Access Program
Netty in Action
Version 10
Copyright2014ManningPublications
FormoreinformationonthisandotherManningtitlesgoto
www.manning.com
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/netty-in-action
brief contents
PART 1: GETTING STARTED
1 Netty Asynchronous and Event-Driven
2 Your first Netty application
3 Netty Overview
P
ART 2: CORE FUNCTIONS/PARTS
4 Transports
5 Buffers
6 ChannelHandler and ChannelPipeline
7 The Codec Framework
8 Provided ChannelHandlers and Codecs
9 Bootstrapping
P
ART 3: NETTY BY EXAMPLE
10 Unit Testing
11 WebSockets
12 SPDY
13 Broadcasting events with UDP
P
ART 4: ADVANCED TOPICS
14 Implement a custom codec
15 EventLoop and thread model
16 Case Studies, Part 1: Droplr, Firebase, and Urban Airship
17 Case Studies, Part 2: Facebook and Twitter
A
PPENDIXES:
A The Community / How to get involved
B Related books
C Related projects
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/netty-in-action
1
Netty Asynchronous and
Event-Driven
1 ........................................................................................................................... 1
1.1 Introducing Netty ........................................................................................... 5
1.2 Building Blocks ............................................................................................... 7
1.2.1 Channels .................................................................................................. 7
1.2.2 Callbacks.................................................................................................. 8
1.2.3 Futures .................................................................................................... 8
1.2.4 Events and Handlers ................................................................................. 10
1.2.5 Putting it All Together ............................................................................... 11
1.3 About this Book ............................................................................................. 12
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/netty-in-action
1
This chapter covers
What is Netty?
Some History
Introducing Netty
Asynchrony and Events
About this Book
WHAT IS NETTY?
Netty is a client/server framework that harnesses the power of Java's advanced networking
while hiding its complexity behind an easy-to use API. Netty provides performance and
scalability, leaving you free to focus on what really interests you - your unique application!
In this first chapter we'll explain how Netty provides value by giving some background on
the problems of high-concurrency networking. Then we'll introduce the basic concepts and
building blocks that make up the Netty toolkit and that we'll be studying in depth in the rest of
the book.
SOME HISTORY
If you had started out in the early days of networking you would have spent a lot of time
learning the intricacies of sockets, addressing and so forth, coding on the C socket libraries,
and dealing with their quirks on different operating systems.
The first versions of Java (1995-2002) introduced just enough object-oriented sugar-
coating to hide some of the intricacies, but implementing a complex client-server protocol still
required a lot of boilerplate code (and a fair amount of peeking under the hood to get it right).
Those early Java APIs (java.net) supported only the so-called "blocking" functions
provided by the native socket libraries. An unadorned example of server code using these calls
is shown in 0.
Listing 1.1 Blocking I/O Example
ServerSocket serverSocket = new ServerSocket(portNumber); //1
Socket clientSocket = serverSocket.accept(); //2
BufferedReader in = new BufferedReader( //3
new InputStreamReader(clientSocket.getInputStream()));
PrintWriter out =
new PrintWriter(clientSocket.getOutputStream(), true);
String request, response;
while ((request = in.readLine()) != null) { //4
if (Done.equals(request) ( //5
break;
}
response = processRequest(request); //6
out.println(response); //7
} //8
1. A ServerSocket is created to listen for connection requests on a specified port.
2. The accept() call blocks until a connection is established. It returns a new Socket which will be used
for the conversation between the client and the server.
©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and
other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders.
https://forums.manning.com/forums/netty-in-action
2
剩余287页未读,继续阅读
资源评论
- 高效能人生2015-10-27netty权威啊,
Super狒狒
- 粉丝: 1
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功