zoukankan      html  css  js  c++  java
  • io多路复用--本质

    io多路复用:用来检测多个socket对象是否有变化

    socket_list = []
    for i in [www.baidu.com.,.,.,.,.]
      client = socket.socket()
      client.setblocking(False)
    #连接
      try:
       client.connect(("i",80)) #阻塞
      except BlockingIOError as e:
       print(e)
      socket_list.append(client)
    #事件循环
    while true: #(检测)
      
    r,w, e = select.select(socket_list,socket_list...,0.05)
    #w    [sk2,sk3], 连接成功了 
    for obj in w;
    obj.send('get /http/1.0...')
    #r   [sk2,sk3],可读
              如果socket中返回内容了,表示可读,要收数据了
    for obj in r:
    response = obj.recv()
             print(response)

    总结

    1.client.setblocking(false)

    2,select.select()  #检测:连接成功,数据回来

  • 相关阅读:
    veil-evasion免杀处理
    对程序"加料"
    堆栈溢出
    ICMP隧道 ptunnle
    socat流量操控
    DNS隧道 iodns
    dns隧道 dns2tcpd
    ssh X协议转发
    ssh动态端口转发
    ssh远程端口转发
  • 原文地址:https://www.cnblogs.com/catherine007/p/8611447.html
Copyright © 2011-2022 走看看