Skip to content

Stateful#

This is an important thing to remember about TCP connections: they're stateful. That means the connection as some state as it's operate on, such as ESTABLISHED, which is to mean the connection is open and ready to receive/send data to the user(s). The TCP connection can also be in a LISTEN state which means the connection is ready to receive new TCP connections, like from a web browser or another client. Then there's CLOSED which, of course, means the connection has no state and has in fact closed and a new connection must be established.

A TCP connection is almost like a pair of tin cans and a piece of string that run between the client and the server - it's persistent and repeatedly used to send data over time until someone cuts the wire and marks the connection as CLOSED.

It's because of this stateful nature that TCP is an "expensive" protocol. That means an active TCP connection uses a lot of system resources and network bandwidth to maintain itself and send data back and forth, between client and server. You do get a lot of functionality, reliability, error checking, etc. for the cost, but it's not the right protocol for all use cases.

When we look at UDP you'll discover why TCP isn't actually used for a lot of the Internet's most common services like DNS.