redis-py is conflict with socket and raise socket 10043 error
<p>I'm tring to write a program to monitor whether hosts are active.We can set ip segment of which host we want to monitor. </p>

<p>Now I use socket send icmp packet so that we can judge whether hosts are active.And I use redis for cache.I have been tried a lot for it.And I got some gains so that I can certainly say that redis-py module is conflict with socket.However,I have no idea to sovle this problem.</p>

<p>The relevant code are following:</p>

<pre><code>class icmpThr(threading.Thread):
  def __init__(self, ipPool, timeout=3, isV6=False):
    threading.Thread.__init__(self)
    self.timeout = timeout
    self.isV6 = isV6

    self.ipPool = ipPool
    self.__id = os.getpid()
    self.__data = struct.pack('d', 0)

  def __checkSum(self, packet):
    cksum = 0
    if len(packet) &amp; 1:
      packet = packet + '\0'
    words = array.array('h', packet)
    for word in words:
      cksum += (word &amp; 0xffff)

    cksum = (cksum &gt;&gt; 16) + (cksum &amp; 0xffff)
    cksum = (cksum &gt;&gt; 16) + (cksum &amp; 0xffff)

    return (~cksum) &amp; 0xffff

  @property
  def __icmpSocket(self):
    if self.isV6:
      Sock = socket.socket(socket.AF_INET6, socket.SOCK_RAW, socket.getprotobyname("ipv6-icmp"))
    else:
      Sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname("icmp"))   #the error raised here
    return Sock

  @property
  def __icmpPacket(self):
    if self.isV6:
      header = struct.pack('BbHHh', 128, 0, 0, self.__id, 0)
    else:
      header = struct.pack('bbHHh', 8, 0, 0, self.__id, 0)
    packet = header + self.__data
    cksum = self.__checkSum(packet)

    if self.isV6:
      header = struct.pack('BbHHh', 128, 0, 0, self.__id, 0)
    else: 
      header = struct.pack('bbHHh', 8, 0, cksum, self.__id, 0)
    return header + self.__data

  def run(self):
    sock = self.__icmpSocket
    packet = self.__icmpPacket

    send = sendThr(packet, self.ipPool, sock)
    recv = recvThr(sock, self.ipPool, send)

    send.start()
    recv.start()

def icmpScan():
  ipDb = redis.Redis(host='localhost',port=6379,db=0)

  ipPool = set(['10.0.0.1'])
  ipDb.set('ip_pool', ipPool)#when I delete this line, it runs well

  icmp = icmpThr(ipPool)

  icmp.start()
  icmp.join()
</code></pre>

<p>What's more, I have been searched about error 10043.It means：Protocol not supported.</p>

<p><img src="https://i.stack.imgur.com/Rwh8O.png" alt="enter image description here"></p>