简体   繁体   中英

socket.gaierror: [Errno 11003] getaddrinfo failed

 if data.find('!scan') != -1:
 nick = data.split('!')[ 0 ].replace(':','')
 targetip = socket.gethostbyname(str(arg))
 sck.send('PRIVMSG ' + chan + " :" ' scanning host' + targetip + '\r\n')
 for i in range(20, 1025):
     s = socket(AF_INET, SOCK_STREAM)
     result = s.connect_ex((targetip, i))
     if (result == 0) :
          s.send('PRIVMSG ' + chan + " :" 'port %d: OPEN' % (i,) + '\r\n')
     s.close()

I get this error:

    targetip = socket.gethostbyname(str(arg))
socket.gaierror: [Errno 11003] getaddrinfo failed

On Windows, socket.gethostbyname() invokes the getaddrinfo() Winsock API call, and errno 11003 - WSANO_RECOVERY may be caused by the SYSTEMROOT environment variable not being set.

Check if os.environ contains SYSTEMROOT before calling socket.gethostbyname, ex:

import os
assert 'SYSTEMROOT' in os.environ

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM