client发送syn至server
此时客户端的状态变为SYN_SENT
client(syn=j)====>server
server收到syn,并发送syn+ack到client,
这种过程server状态由listen变为SYN_RECV,并等待客户端再次发来ack数据
client<=========server(syn=k,ack=j+1)
client接收到server发过来的syn+ack,并向服务端发送ACK,服务器接收后由SYN_RECV变为ESTABLISHED
client(ACK(ack=k+1))========>server
此种情况下,服务端在三次握手的变迁是
LISTEN->SYN_RECV ->ESTABLISHED
客户端的三次握手的变迁是
SYN_SENT ->ESTABLISHED
客户端主动断掉当前连接:
client---->FIN----->server(client由ESTABLISHED-->FIN_WAIT1)
client<----ACK<----server
client处于FIN_WAIT_2状态,server由ESTABLISHED-->close_wait状态
client<----FIN<-----server
这时,server发送FIN给client,server置为LAST_ACK
client------->ACK------>server
client回应ACK,那么server的套接字才真正为close状态
阅读(1065) | 评论(0) | 转发(0) |