2
 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
SourD
  • 2,771
  • 7
  • 28
  • 28
  • Could you be a little more specific what your question is and give some additional info? What is in arg? Are you sure you have access to your DNS server? What have you done so far to try and fix this problem? – Robert S. Barnes Apr 13 '11 at 20:12
  • @Robert S. Barnes arg is the argument a user gives after !scan.. example: !scan IP – SourD Apr 13 '11 at 20:31
  • What is the value of `arg`? Do you have your resolvers setup correctly? – Burhan Khalid Jan 23 '17 at 05:56

1 Answers1

1

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
Sébastien Trottier
  • 2,226
  • 2
  • 15
  • 11