Chapter 4. Transports

 

This chapter covers

  • OIO—blocking transport
  • NIO—asynchronous transport
  • Local transport—asynchronous communications within a JVM
  • Embedded transport—testing your ChannelHandlers

The data that flows through a network always has the same type: bytes. How these bytes are moved around depends mostly on what we refer to as the network transport, a concept that helps us to abstract away the underlying mechanics of data transfer. Users don’t care about the details; they just want to be certain that their bytes are reliably sent and received.

If you have experience with network programming in Java, you may have discovered at some point that you needed to support a great many more concurrent connections than expected. If you then tried to switch from a blocking to a non-blocking transport, you might have encountered problems because the two network APIs are quite different.

Netty, however, layers a common API over all its transport implementations, making such a conversion far simpler than you can achieve using the JDK directly. The resulting code will be uncontaminated by implementation details, and you won’t need to perform extensive refactoring of your entire code base. In short, you can spend your time doing something productive.

4.1. Case study: transport migration

4.2. Transport API

4.3. Included transports

4.4. Transport use cases

4.5. Summary

sitemap