Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1398140
  • 博文数量: 277
  • 博客积分: 2551
  • 博客等级: 少校
  • 技术积分: 3918
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-21 22:46
文章分类

全部博文(277)

文章存档

2017年(3)

2016年(9)

2015年(65)

2014年(27)

2013年(85)

2012年(61)

2011年(27)

分类: LINUX

2016-08-08 23:43:11

查看内核源代码中的定义
net/ipv4/tcp.c
/*

Description of States:

 *

 *    TCP_SYN_SENT         

sent a connection request, waiting for ack

 *

 *    TCP_SYN_RECV        

received a connection request, sent ack,

 *                         waiting for final ack in three-way handshake.

 *

 *    TCP_ESTABLISHED          

connection established

 *

 *    TCP_FIN_WAIT1        

our side has shutdown, waiting to complete

 *                         transmission of remaining buffered data

 *

 *    TCP_FIN_WAIT2        

all buffered data sent, waiting for remote

 *                         to shutdown

 *

 *    TCP_CLOSING           

both sides have shutdown but we still have

 *                         data we have to finish sending

 *

 *    TCP_TIME_WAIT       

timeout to catch resent junk before entering

 *                         closed, can only be entered from FIN_WAIT2

 *                         or CLOSING.  Required because the other end

 *                         may not have gotten our last ACK causing it

 *                         to retransmit the data packet (which we ignore)

 *

 *    TCP_CLOSE_WAIT            

remote side has shutdown and is waiting for

 *                         us to finish writing our data and to shutdown

 *                         (we have to close() to move on to LAST_ACK)

 *

 *    TCP_LAST_ACK         

out side has shutdown after remote has

 *                         shutdown.  There may still be data in our

 *                         buffer that we have to finish sending

 *

 *    TCP_CLOSE        

socket is finished

 */

tcp客户端connect发起之后,协议栈就会发送SYN给服务器
                                      协议栈收到来自服务器的响应后,发出Ack后,就进入了established
tcp服务器在收到SYN后,发送SYN+ACK后就进入SYN_RECVD,再次收到客户端的Ack时,也进入established
可见established状态连接的双方进入的时机是有先后的,客户端是先进入的,服务器是后进入的

阅读(1773) | 评论(0) | 转发(0) |
0

上一篇:linux命令深入

下一篇:tcp中send错误码

给主人留下些什么吧!~~