为什么要三次握手?
Client —>Server
Server —> Client
Client —> Server
双方都要确定彼此收到了要开始TCP传输的信息,第一个消息的告诉服务端,我要开始tcp连接,服务端回复收到,客户端再回复收到了服务端回复了。确定可以开始。
四次挥手
A和B说我们断开吧,B回复好的,接着告诉A我断开了,收到B回复,A也把断开消息回复给B,后两次是结束连接。
A——》B
B——》A
B——》A
A——》B
GET /home HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: Pycharm-30407d25=f3022c68-0a17-4844-b153-73b297323884
HTTP/1.1 200 OK
content-Type: text/html
content-Length: 13