简体   繁体   中英

Server connection issue: “socket.gaierror: [Errno 11004] getaddrinfo failed”

socket.gaierror: [Errno 11004] getaddrinfo failed

I get this error for a simple ircbot connection script

import sys
import socket
import string

HOST="irc.quakenet.net"
PORT=6667
NICK="MonstaBot"
IDENT="mbotv1"
REALNAME="MonstarulesBot"
readbuffer=""

s=socket.socket( )
s.connect((HOST, PORT))
s.send("NICK %s\r\n" % NICK)
s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))

while 1:
    readbuffer=readbuffer+s.recv(1024)
    temp=string.split(readbuffer, "\n")
    readbuffer=temp.pop( )

    for line in temp:
        line=string.rstrip(line)
        line=string.split(line)

        if(line[0]=="PING"):
            s.send("PONG %s\r\n" % line[1])

Any clues as to why I got that error? If this helps a bit here was the full error message.

File "monstabotrun.py", line 13, in <module>
s.connect((HOST, PORT))
File "C:\Python27\lib\socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.gaierror: [Errno 11004] getaddrinfo failed

It should be irc.quakenet.org , not irc.quakenet.net . It gives an error because irc.quakenet.net does not resolve.

The hostname may not be resolved. If there is some limitation in resolving a hostname, you may use the IP address.

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