Search code examples
pythonsocketsirc

Python socket errno -3 on run


Upon running and testing a few IRC bots on a old laptop running Lucid puppy 5.2 after installing Python 1.6 (the only python .pet i could find), every few times i run the python file, i get this strange error:

Traceback (most recent call last):
    File "bot.py!, line 77, in <module>
       irc.connect ( (irc_network, irc_port) ) 
    File "<string>", Line 1, in connect
socket.gaierror: [Errno -3] Temporary failure in name resolution

this is the section of code this error is occouring on:

irc_network = 'irc.esper.net'
irc_port = 5555
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect ( ( irc_network, irc_port ) )

I'm just using the socket module for this, with no third party imports of any kind. I have no idea what this error is and what it means, as a quick google turned up nothing for me.

The purplexing fact is that i can just try and run the bot again, without changing anything, and it runs fine.

Thank you for your time.


Solution

  • The only I can think of that your DNS resolver doesn't work as it should. Here this code runs fine.


    BTW (just as a comment), if you replace

    irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
    irc.connect ( ( irc_network, irc_port ) )
    

    with

    irc = socket.create_connection( ( irc_network, irc_port ) )
    

    you are more future proof as you don't restrict yourself to an old protocol which will disappear in the next decades.