当前位置:网站首页>TCP三次握手、四次断开
TCP三次握手、四次断开
2022-07-26 22:50:00 【less than _ermi】
TCP的三次握手、四次断开主要关注TCP头部序列号和确认号以及几个标记部位。三次握手就是建立一个TCP连接时,确认客户端和服务端的序列号。
三次握手:最开始的时候,客户端和服务端都处于关闭状态,服务器主动监听某个端口,客户端随机生成序列号,发送给服务端连接请求,在服务端接收到了客户端的连接请求后,自己也初始化对应的序列号,发送给客户端,客户端收到服务端的消息后便知道了服务端已经知道自己的序列号并且自己也知道了服务端的序列号,此时客户端只需要告诉服务端自己已经接收到了它发送过来的序列号,当服务端收到客户端发给他的消息(我已经接收到了你的序列号)的时候,客户端和服务端连接就确立了。总结下来就是双方把自己的序列号发给对方,看对方是否可以收到,三次握手就可以看到双方都有接收和发送能力。
四次断开:建立连接完之后,客户端和服务端都处于确立连接的状态,如果客户端想要主动断开连接,告诉服务端我要主动断开连接,服务端收到消息后告知客户端收到的消息已确认接收无误。这时候,等待服务端确认已经没有数据返回给客户端后,告诉客户端断开连接的信息,自己进入等待连接断开的状态,客户端收到断开连接的信息告诉服务端确认断开,自己进入连接结束的状态,服务端收到确认断开信息后,服务端就进入了关闭状态,客户端在连接结束状态等待一会儿过后也进入了关闭状态。
边栏推荐
猜你喜欢

【C语言程序设计】分支结构

C语言——while语句、dowhile语句、for循环和循环结构、break语句和continue语句

有趣的C语言

7.16 written examination of Duoyi network

WAN technology experiment

Introduction to STM32 lesson 1

The latest C language introduction and advanced - the most complete and detailed C language tutorial in history!! Section 1 - overview of C language

About unsafe problems such as fopen and strError encountered in vs2022 or advanced version running environment

OSPF static experiment

C语言——关系运算符和逻辑运算符、if语句、switch语句、分支结构的嵌套
随机推荐
RISC-V工具链编译笔记
Republishing and routing strategy of OSPF
2022 latest Tiktok live broadcast monitoring (II) streaming media download in live broadcast room
Codeforces Round #796 (Div. 2), problem: (1688C) Manipulating History
Golang -- parse yaml file
6.30 didi surface warp (one side + two sides)
JVM面试题(面试必备)
Ogeek meetup phase I, together with cubefs, is hot
RS-485总线通信应用
js中的数组方法和循环
Simple application of rip V2 (V2 configuration, announcement, manual summary, ripv2 authentication, silent interface, accelerating convergence)
静态路由基本配置 实现全网可达
7.16 written examination of Duoyi network
Lecture 4 - explain GPIO_ Write function and related routines
指针得真正奥义!!!
数字集成电路:MOS管器件章(二)
Lora通信应用开发
7.7 sheen Xiyin written test
记录HandsomeBlog的star用户
Golang中的错误处理