Last Updated: May 17, 2026
A TCP socket is the layer underneath HTTP, gRPC, WebSockets, and most of the protocols you've used as a client. HTTP is built on TCP; this lesson is the layer below. C# exposes TCP through System.Net.Sockets, with TcpListener and TcpClient as the friendly wrappers on top of the raw Socket class. This lesson covers when dropping below HTTP is the right call, how to write an async TCP server and client, the framing problem that catches almost everyone the first time, and how to shut connections down without losing data or leaking handles.