Part 2. Codecs

 

A network sees data as just a sequence of raw bytes. Our applications, however, structure these bytes in a way that has meaning as information. Converting data to and from the network byte stream is one of the most common programming tasks. You may, for example, need to work with a standard format or protocol such as FTP or Telnet, implement a proprietary binary protocol defined by a third party, or extend a legacy message format created by your own organization.

Components that handle the conversion of application data to and from a network format are called encoders and decoders, respectively, and a single component with both capabilities is referred to as a codec. Netty provides a range of tools for creating all of these, from prebuilt classes specialized for well-known protocols such as HTTP and base64 to generic message transformation codecs that you can customize for your specific needs.

Chapter 10 provides an introduction to encoders and decoders. You’ll learn about Netty’s basic codec classes by studying some typical use cases. As you learn how these classes fit into the overall framework, you’ll find that they are built on the same APIs you’ve already studied, so you’ll be able to use them right away.