liveBook · Manning

Asynchronous server

As explained in C# Concurrency: Asynchronous and multithreaded programming

An asynchronous server handles client operations without synchronously blocking a thread while waiting for external activity.

An asynchronous server handles client operations without synchronously blocking a thread while waiting for network or disk activity. It suits mostly I/O-bound work, such as serving static files or making database queries. section 6.1

A socket accepts connections asynchronously, while each request uses asynchronous file reads and sends. Compared with one thread per request, this reduces thread growth under load, although asynchronous handling is not automatically faster at light loads.

Static-file server

A server listens on port 7777, accepts connections with AcceptAsync, reads somefile.bin with ReadAsync, and sends each buffer asynchronously. At 200–300 connections, the asynchronous version records no failures while the threaded version records many.

How C# Concurrency: Asynchronous and multithreaded programming covers it

How deep it goes
Shows complete socket and file-operation implementations, then measures failures, elapsed time, and thread counts against threading.
Examples
Compares static-file servers using one thread per request or asynchronous socket and file operations under loads of 50 to 400 connections.
What you can do after
Build and evaluate a C# asynchronous static-file server against a thread-per-request implementation using measured connection loads.
How it connects
Connects asynchronous programming with multithreading, socket programming, file I/O, and load testing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of C# Concurrency: Asynchronous and multithreaded programming. The section links point to the parts of the book it draws on.