A connection is simply a virtual pathway between two endpoints. With TCP, you open up the connection and start sending data through. It's guaranteed to arrive at the other end in order (assuming the network doesn't fail). Then you close down the connection.
For the duration of the connection, the two ends talk to each other, acknowledging receipt of packets, to ensure there's no loss or duplication.
With UDP, it's slightly different. You basically just throw a packet out there with a destination address and it may or may not arrive - that's the U in UDP (unreliable).
You shouldn't be lulled into thinking the connection of TCP results in all packets taking the same physical path. They will be routed around problem areas if necessary.
As for your update, the connection is established after the following has happened:
- a
SYN
packet has been sent from the initiator.
- the responder has sent back a
SYN-ACK
packet.
- the initiator has sent back another
ACK
packet.
This is the session establishment protocol for TCP. The packets themselves are normal packets with the SYN
and/or ACK
flags set in the header.
The seminal book on TCP (and other protocols) is Stevens, get yourself a copy of this if you want a dead-tree version - I've had this for ages. Or, of course, there's the Wikipedia stuff. Both of these are pretty heavy going for the casual enquirer, but well worth it if you're at all interested in going deeper - my own preference would be for the book, it ranks up there with Knuth on my bookshelf.