zoukankan      html  css  js  c++  java
  • shutdown(0)和shutdown(1)

    正常的四次挥手:
    
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
    16:40:28.015509 IP 192.168.137.1.50566 > node1.webcache: Flags [S], seq 2511573816, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
    16:40:28.015554 IP node1.webcache > 192.168.137.1.50566: Flags [S.], seq 1665892250, ack 2511573817, win 1536, options [mss 256,nop,nop,sackOK,nop,wscale 6], length 0
    16:40:28.016825 IP 192.168.137.1.50566 > node1.webcache: Flags [.], ack 1665892251, win 16482, length 0
    
    
    
    
    16:40:38.003254 IP 192.168.137.1.50566 > node1.webcache: Flags [F.], seq 2511573817, ack 1665892251, win 16482, length 0
    16:40:38.003896 IP node1.webcache > 192.168.137.1.50566: Flags [F.], seq 1665892251, ack 2511573818, win 24, length 0
    16:40:38.004336 IP 192.168.137.1.50566 > node1.webcache: Flags [.], ack 1665892252, win 16482, length 0
    
    
    print(socket.SHUT_RDWR)  2
    print(socket.SHUT_RD)    0
    print(socket.SHUT_WR)    1
    
    
    关闭read:
    
    import socket
    import struct
    import time
    s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.connect(("192.168.137.2",8080))
    s.shutdown(0)
    time.sleep(10)
    
    
    
    
    node1:/root/test#tcpdump -S -i eth1 '((tcp) and  (port 8080) and (host 192.168.137.1))'
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
    
    17:06:50.569831 IP 192.168.137.1.51743 > node1.webcache: Flags [S], seq 2708657781, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
    17:06:50.569934 IP node1.webcache > 192.168.137.1.51743: Flags [S.], seq 4031762968, ack 2708657782, win 1536, options [mss 256,nop,nop,sackOK,nop,wscale 6], length 0
    17:06:50.570212 IP 192.168.137.1.51743 > node1.webcache: Flags [.], ack 4031762969, win 16482, length 0
    
    shutdown(0)不发送FIN
    
    
    
    
    import socket
    import struct
    import time
    s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.connect(("192.168.137.2",8080))
    time.sleep(10)
    
    s.shutdown(1)
    print '111111111111111'
    time.sleep(100)
    
    
    shutdown(1)
    
    
    17:08:08.185555 IP 192.168.137.1.51799 > node1.webcache: Flags [F.], seq 1521092233, ack 2941928650, win 16482, length 0
    17:08:08.185692 IP node1.webcache > 192.168.137.1.51799: Flags [F.], seq 2941928650, ack 1521092234, win 24, length 0
    17:08:08.186009 IP 192.168.137.1.51799 > node1.webcache: Flags [.], ack 2941928651, win 16482, length 0
    
  • 相关阅读:
    区别@ControllerAdvice 和@RestControllerAdvice
    Cannot determine embedded database driver class for database type NONE
    使用HttpClient 发送 GET、POST、PUT、Delete请求及文件上传
    Markdown语法笔记
    Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
    Mysql 查看连接数,状态 最大并发数(赞)
    OncePerRequestFilter的作用
    java连接MySql数据库 zeroDateTimeBehavior
    Intellij IDEA 安装lombok及使用详解
    ps -ef |grep xxx 输出的具体含义
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348528.html
Copyright © 2011-2022 走看看