Python套接字irc机器人-socket.gaierror:[Errno 11001] getaddrinfo失败

时间:2018-07-12 15:39:18

标签: python shared-libraries

args = b'' 
for index,item in enumerate(arg) : 
    if index > 3: 
        if args == b'': 
            args = item 
        else : 
            args += b' ' + item

elif data.find(b'!scan') != -1:
    nick = data.split(b'!')[ 0 ].replace(b':',b'')
    targetip = socket.gethostbyname(str(arg))
    sck.send(b'PRIVMSG ' + chan + b" :" + ' scanning host' + targetip + b'\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(b'PRIVMSG ' + chan + b" :" b'port %d: OPEN' % (i,) + b'\r\n')
            s.close()   

我收到socket.gaierror:当我尝试扫描特定IP时,[Errno 11001] getaddrinfo失败。 IRC中的命令是(!scan IP)。机器人刚刚退出,并给了我上面的错误。

arg的目的是在IP地址!scan之后找到字符串或参数。例如:!扫描参数。

0 个答案:

没有答案
相关问题