Question

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
Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top