Reputation: 2920
I wonder to know what is a connection in TCP really is
For example suppose the client is in Asia and the server is in USA, when a connection has been established what would happen over that connection? what would happen if the connection is open for a minute (long-polling for example).
I mean does a heartbeat will be send periodically over the routers in the middle or by the term connection
we only mean something dedicated in both hosts (client and server) to persist some data? in that case I don't know why we say the cost of opening a connection is high.
Thanks in advance.
Upvotes: -4
Views: 70
Reputation: 311
The TCP connection essentially is the connection information which is stored on both ends. The information is deleted on explicit connection close signal or on timeout. There are also keep-alive packets which prevent timeouts to be elapsed.
This is defined in details in rfc9293 https://datatracker.ietf.org/doc/html/rfc9293#name-closing-a-connection and https://datatracker.ietf.org/doc/html/rfc9293#name-timeouts
Upvotes: 2
Reputation: 1264
TCP is a quite passive protocol, by default it won't send heart beat if you don't write to the stream.
So applications usually write their own "high-level" protocols which sometimes include the heart-beating thing. But if you do send messages, the other side will send acks to you.
The connection is not a real connection, but some consensus between you and the server. Don't forget there are half-open connections.
By design TCP is only about the server and the client, the device between should not care the "connection". But that's before Firewall or NAT is a thing. Today some devices may detect your "connection" be inactive and send reset message to you.
Upvotes: 2