Book Image

Hands-On Network Programming with C# and .NET Core

By : Sean Burns
Book Image

Hands-On Network Programming with C# and .NET Core

By: Sean Burns

Overview of this book

The C# language and the .NET Core application framework provide the tools and patterns required to make the discipline of network programming as intuitive and enjoyable as any other aspect of C# programming. With the help of this book, you will discover how the C# language and the .NET Core framework make this possible. The book begins by introducing the core concepts of network programming, and what distinguishes this field of programming from other disciplines. After this, you will gain insights into concepts such as transport protocols, sockets and ports, and remote data streams, which will provide you with a holistic understanding of how network software fits into larger distributed systems. The book will also explore the intricacies of how network software is implemented in a more explicit context, by covering sockets, connection strategies such as Transmission Control Protocol (TCP) and User Datagram Protocol (UDP), asynchronous processing, and threads. You will then be able to work through code examples for TCP servers, web APIs served over HTTP, and a Secure Shell (SSH) client. By the end of this book, you will have a good understanding of the Open Systems Interconnection (OSI) network stack, the various communication protocols for that stack, and the skills that are essential to implement those protocols using the C# programming language and the .NET Core framework.
Table of Contents (26 chapters)
Free Chapter
Section 1: Foundations of Network Architecture
Section 2: Communicating Over Networks
Section 3: Application Protocols and Connection Handling
Section 4: Security, Stability, and Scalability
Section 5: Advanced Subjects

What this book covers

Chapter 1, Networks in a Nutshell, introduces readers to the fundamentals of computer networks, and the challenges of writing software for use on distributed systems.

Chapter 2, DNS and Resource Location, explores the basics of resource location and the origins of the DNS.

Chapter 3, Communication Protocols, investigates the OSI network stack and the variety of communication protocols designed for each layer of that stack.

Chapter 4, Packets and Streams, looks at how data is encapsulated in packets and how groups of packets are consumed by your software as a stream.

Chapter 5, Generating Network Requests in C#, takes a deep dive into the request/response model of network communication and how that model is implemented in C#.

Chapter 6, Streams, Threads, and Asynchronous Data, looks at how C# programs can be designed to consume data streams from remote resources asynchronously, thereby improving performance and reliability.

Chapter 7, Error Handling over the Wire, looks closely at how to design and implement error-handling strategies in network software.

Chapter 8, Sockets and Ports, examines how logical connections are established between network hosts by mapping a socket in your application code to a port on your network interface.

Chapter 9, HTTP in .NET, takes a thorough look at how every aspect of HTTP is implemented within the context of C# and .NET Core. It looks at implementing HTTP clients and server applications using ASP.NET Core and the System.Net.Http library.

Chapter 10, FTP and SMTP, looks at some of the less commonly leveraged protocols of the application layer of the OSI network stack, implementing a fully functional FTP server in the process.

Chapter 11, The Transport Layer – TCP and UDP, takes a close look at the transport layer of the OSI network stack, exploring the distinction between connection-based and connectionless communication protocols, and looking at how to implement each in C#.

Chapter 12, The Internet Protocol, explores the backbone of the modern internet by looking at how the Internet Protocol (IP) provides for device addressing and packet delivery.

Chapter 13, Transport Layer Security, looks at how the SSL and TLS were designed to provide security for data transmitted over global, unsecured networks, and how to implement TLS in .NET Core applications.

Chapter 14, Authentication and Authorization on Networks, considers how you can validate the identity of users of your network software and restrict access to different features and resources based on your users' permissions.

Chapter 15, Caching Strategies for Distributed Systems, looks at the various benefits of caching different resources in your network software for performance and reliability improvements.

Chapter 16, Performance Analysis and Monitoring, takes a close look at how to monitor the health and performance of your network applications, and how to respond to, and reduce the impact of, network unreliability in relation to your software.

Chapter 17, Pluggable Protocols in .NET Core, looks at the .NET concept of a pluggable protocol, and how you can use it to define your own custom application layer network protocols, and incorporate those protocols seamlessly into your .NET applications.

Chapter 18, Network Analysis and Packet Inspection, examines the tools and resources available in the .NET Core framework for investigating network traffic and the state of network devices on your host machine. It looks at how you can investigate the content of network traffic being processed by your host with packet inspection, and how you can use the information gained by packet inspection to respond to security risks.

Chapter 19, Remote Logins and SSH, looks at the origins of the SSH protocol and how it enables secure access to remote resources over an unsecured network. It looks at the most popular C# library for interacting with remote hosts via SSH and considers the range of applications you might build on top of the SSH protocol.