Book Image

Network Programming with Rust

By : Abhishek Chanda
Book Image

Network Programming with Rust

By: Abhishek Chanda

Overview of this book

Rust is low-level enough to provide fine-grained control over memory while providing safety through compile-time validation. This makes it uniquely suitable for writing low-level networking applications. This book is divided into three main parts that will take you on an exciting journey of building a fully functional web server. The book starts with a solid introduction to Rust and essential networking concepts. This will lay a foundation for, and set the tone of, the entire book. In the second part, we will take an in-depth look at using Rust for networking software. From client-server networking using sockets to IPv4/v6, DNS, TCP, UDP, you will also learn about serializing and deserializing data using serde. The book shows how to communicate with REST servers over HTTP. The final part of the book discusses asynchronous network programming using the Tokio stack. Given the importance of security for modern systems, you will see how Rust supports common primitives such as TLS and public-key cryptography. After reading this book, you will be more than confident enough to use Rust to build effective networking software
Table of Contents (11 chapters)

What this book covers

Chapter 1, Introduction to Client/Server Networking, starts the book with a gentle introduction to computer networking from the ground up. This includes IP addressing, TCP/UDP, and DNS. This forms the basis of our discussions in later chapters.

Chapter 2, Introduction to Rust and its Ecosystem, contains an introduction to Rust. This is an overall introduction that should be good enough to get the reader started. We do assume some familiarity with programming.

Chapter 3, TCP and UDP Using Rust, dives into using Rust for networking. We start with basic socket programming using the standard library. We then look at some crates from the ecosystem that can be used for network programming.

Chapter 4, Data Serialization, Deserialization, and Parsing, explains that an important aspect of networked computing is handling data. This chapter is an introduction to serializing and deserializing data using Serde. We also look at parsing using nom and other frameworks.

Chapter 5, Application Layer Protocols, moves up a layer to look at protocols that operate above TCP/IP. We look at a few crates to work with, such as RPC, SMTP, FTP, and TFTP.

Chapter 6, Talking HTTP in the Internet, explains that arguably the most common application of the internet is HTTP. We look at crates such as Hyper and Rocket which are used for writing HTTP servers and clients.

Chapter 7, Asynchronous Network Programming Using Tokio, looks at the Tokio stack for asynchronous programming using futures, streams, and event loops.

Chapter 8, Security, delves into securing the services we have described so far. This is using certificates and secret keys.

Chapter 9, Appendix, discusses a number of crates have appeared that propose alternate ways of doing things already covered in this book. This includes the async/await syntax, parsing using Pest, and so on. We will discuss some of these in the appendix.