TCP Flashcards
Describe the steps of a TCP client
1) Make a socket and connect it to a port
2) Prepare input stream (from server)
3) Prepare output stream (to server)
4) Write request bytes to output stream
5) Read response bytes from input stream
6) …
7) Close socket and terminate connection
Describe the steps of a TCP server
1) Make a ServerSocket with known port
2) (repeat)
3) .accept a new client connection represented by a new Socket
4) Make a thread to handle the client
Name 4 TCP considerations
Message size, message destination, blocking, failure model
Describe message size
Application reads/writes any number of bytes at a time until the connection is closed - the application does not see any message boundaries so needs to communicate boundaries explicitly in the bytes sent
Describe message destination
A server can accept connection requests from any client - once the connection is established then bytes are communicated only between that pair of processes
Describe blocking
A limited amount of data is buffered at sender and receiver sockets and sends will block once the sender buffer is full (known as flow control)
Describe failure model
Communication is reliable short of complete connection failure
Lost messages are automatically retransmitted, duplicate packets are discarded and out-of-order packets are reordered using sequence numbered
If a loss is not resolved within a time limit then the whole connection fails
Describe the uses of TCP
Can transfer almost all data reliably and/or in large amounts
e.g. HTTP, SSH, FTP, SMTP