Netty 4.x User manual

Source: Internet
Author: User

Preface question

Now we use common applications and libraries for communication, for example: we typically use an HTTP client library to invoke remote services from a Web service to obtain information from a single server. However, a generic protocol or its implementation sometimes does not scale well. It's like we don't use HTTP servers to transfer oversized files, e-mail messages, and near-real-time information, such as financial information and multi-player data. These scenarios require a highly optimized protocol implementation. For example, you might want to implement an AJAX-based chat application system, streaming media, and large file transfer HTTP servers. You may even want to design and implement a new protocol that precisely meets your needs. Another unavoidable scenario is that you have to deal with a legacy proprietary protocol to ensure that you can communicate with the old system. In this case, it is important how quickly we can implement the protocol without sacrificing the stability and performance of the final application.

Nowadays we use the general purpose applications or libraries to communicate with each other. For example, we often use an HTTP client library to retrieve information from a Web server and to invoke a remote Procedur e call via Web services. However, a general purpose protocol or IT implementation sometimes does not scale very well. It's like how we don't use the purpose HTTP server to exchange huge files, e-mail messages, and Near-realtime Messa Ges such as financial information and multiplayer game data. What's required is a highly optimized protocol implementation which are dedicated to a special purpose. For example, might want to implement an HTTP server which are optimized for ajax-based chat application, media streamin g, or large file transfer. You could even want to design and implement a whole new protocol which are precisely tailored to your need. Another inevitable case was when you had to deal with a legacy proprietary protocol to ensure the interoperability with an OldSystem. What matters in this case is how quickly we can implement that protocol while not sacrificing the stability and Performanc E of the resulting application.

Solution Solutions

The Netty Project is an asynchronous event-driven network application framework that enables rapid development of maintainable high-performance, high-scalability protocol server and client tools.

In other words, Netty is a NIO client-server framework that enables rapid and simple development of network applications such as protocol servers and clients. It greatly simplifies network programming, such as socket server development for TCP and UDP.

"Fast and easy" does not mean that the application will have maintainability and performance issues. Netty is carefully designed to gain experience from implementing a large number of protocols, such as ftp,smtp,http and a variety of secondary and text-based legacy protocols, so Netty successfully finds a way to achieve simple development, performance, stability, and flexibility at the same time.

Some users may also find that some other frameworks claim to have the same advantages, and you may ask what makes Netty so different. The answer is the idea we build. Netty, from day one, wants to give the user the most comfortable experience, whether it's an API or an implementation. It's not tangible, but you'll realize the idea of making your life easier, as if you were reading this guide and using Netty.

The Netty Project is a effort to provide an asynchronous Event-driven Network application framework and tooling For the rapid development of maintainable high-performance High-scalability protocol servers and clients.

In other words, Netty are an NIO Client server framework which enables quick and easy development of network applications S Uch as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server development.

' Quick and easy ' does isn't mean that a resulting application would suffer from a maintainability or a performance issue. Netty have been designed carefully with the experiences earned from the implementation of a lot of protocols such as FTP, S MTP, HTTP, and various binary and text-based legacy protocols. As a result, Netty have succeeded to find a from achieve ease of development, performance, stability, and flexibility wit Hout a compromise.

Some users might already has found other network application framework which claims to has the same advantage, and you mi Ght want to ask about makes Netty so different from them. The answer is the philosophy it's built on. Netty is designed to give you the very comfortable experience both in terms of the API and the implementation from the day One. It isn't something tangible but you'll realize that this philosophy would make your life much easier as you read this GU IDE and play with Netty.

Netty Components Diagram

Entry

This chapter introduces the core architecture of Netty and gives you a quick start with some simple examples. When you finish this chapter, you can immediately write a client server program based on the Netty.

If you like top-down learning things, you might want to start with the second chapter, the architecture Introduction, and then back here.

This chapter tours around, the core constructs of Netty with simple examples-let you get started quickly. You'll be able to write a client and a server in top of Netty right away when you were at the end of this chapter.

If you prefer top-down approach in learning something, you might want to start from Chapter 2, architectural Overview and Get back here.

Before you get started

The minimum requirements for running examples in this chapter are only two, the latest Netty version and JDK 1.6. The latest version of Netty is available on the Netty download page. To download the correct version of the JDK, refer to the JDK's provider website

As you read, you may have a lot of questions about the class used in this chapter, and when you want to know more about them, refer to API reference. For your convenience, all classes are linked to the API reference, and if there are any error messages, grammatical and spelling errors, or if you have good suggestions to improve our documentation, please contact the Netty community immediately.

The minimum requirements to run the examples which is introduced in this chapter is only; The latest version of Netty and JDK 1.6 or above. The latest version of Netty is available in the Project download page. To download the right version of the JDK, please refer to your preferred JDK vendor ' s Web site.

As you read, you might has more questions about the classes introduced in this chapter. Please refer to the API reference whenever your want to know more about them. All class names in this document is linked to the online API reference for your convenience. Also, please don ' t hesitate to contact the Netty Project community and let us know if there ' s any incorrect information, E Rrors in grammar and typo, and if you had a good idea to improve the documentation

Example

The following examples you can extract from the example jar of the Netty installation package to view the source code

    • Writing a Discard Server
    • Looking into the Received Data
    • Writing an Echo Server
    • Writing a Time Server
    • Writing a Time Client
    • Dealing with a stream-based Transport
    • Speaking in POJO instead ofByteBuf
    • Shutting down Your application
Summarize

In this chapter, we quickly learned how to write a completed Web application based on Netty

There are also many examples in the Io.netty.example package to view

In this chapter, we had a quick tour of the Netty with a demonstration on what to write a fully working network application on Top of Netty.

There is more detailed information on Netty in the upcoming chapters. We also encourage you to review the Netty examples in the package io.netty.example .

Please also note that the community are always waiting for your questions and ideas to help you and keep improving Netty an D its documentation based on your feedback.

Netty 4.x User manual

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.