code: def get_asn_whois(self, retry_count=3):
          
  
          try:
  
              # Create the connection for the Cymru whois query.
              conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
              conn.settimeout(self.timeout)
              log.debug('ASN query for {0}'.format(self.address_str))
              conn.connect((CYMRU_WHOIS, 43))
  
              # Query the Cymru whois server, and store the results.
              conn.send((
                  ' -r -a -c -p -f {0}{1}'.format(
                      self.address_str, '\r\n')
              ).encode())
  
              data = ''
              while True:
  
                  d = conn.recv(4096).decode()
                  data += d
  
                  if not d:
  
                      break
  
              conn.close()
  
              return str(data)
  
          except (socket.timeout, socket.error) as e:  # pragma: no cover
  
              log.debug('ASN query socket error: {0}'.format(e))
              if retry_count > 0:
  
                  log.debug('ASN query retrying (count: {0})'.format(
                      str(retry_count)))
                  return self.get_asn_whois(retry_count - 1)
  
              else:
  
                  raise ASNLookupError(
                      'ASN lookup failed for {0}.'.format(self.address_str)
                  )
  
          except:  # pragma: no cover
  
              raise ASNLookupError(
                  'ASN lookup failed for {0}.'.format(self.address_str)
              )
docs: The function for retrieving ASN information for an IP address from
          Cymru via port 43/tcp (WHOIS).
  
          Args:
              retry_count (:obj:`int`): The number of times to retry in case
                  socket errors, timeouts, connection resets, etc. are
                  encountered. Defaults to 3.
  
          Returns:
              str: The raw ASN data.
  
          Raises:
              ASNLookupError: The ASN lookup failed.