def _convert_host_to_hex(host):
 ips = []
 if (host is not None):
  for (family, ip) in _convert_host_to_ip(host):
   hexip_nf = binascii.b2a_hex(socket.inet_pton(family, ip))
   hexip_hf = ''
   for i in range(0, len(hexip_nf), 8):
    ipgroup_nf = hexip_nf[i:(i + 8)]
    ipgroup_hf = socket.ntohl(int(ipgroup_nf, base=16))
    hexip_hf = ('%s%08X' % (hexip_hf, ipgroup_hf))
   ips.append((family, hexip_hf))
 return ips

def _convert_host_to_hex ( host ) : ips = [ ] if ( host is not None ) : for ( family , ip ) in _convert_host_to_ip ( host ) : hexip_nf = binascii . b2a_hex ( socket . inet_pton ( family , ip ) ) hexip_hf = '' for i in range ( 0 , len ( hexip_nf ) , 8 ) : ipgroup_nf = hexip_nf [ i : ( i + 8 ) ] ipgroup_hf = socket . ntohl ( int ( ipgroup_nf , base = 16 ) ) hexip_hf = ( '%s%08X' % ( hexip_hf , ipgroup_hf ) ) ips . append ( ( family , hexip_hf ) ) return ips
convert the provided host to the format in /proc/net/tcp* /proc/net/tcp uses little-endian four byte hex for ipv4 /proc/net/tcp6 uses little-endian per 4b word for ipv6 args: host: string with either hostname .