Python - Telnetlib socket.gaierror: -


I am trying to create a telnet in Teamspeak 3 server query through Python, this is my code:

__writer = 'importer' import telnetblab, socket HOST =" unlightedgaming.com "port = 10011 = In). \ N "Try: tn = telnetlib.Telnet (HOST [i], 23,3) except socket.timeout: #tn = telnetlib.Telnet pass (host, port, timeout) # Telnetblab Telnet (host, port, timeout) Tn.read_until ("Welcome to TeamSpeak 3 ServerClife Interface") Print tn.read_all ()

But I accidentally get this error It can not be detected.

  C: \ Python 27 \ python.exe C: /Users/Khailz/PycharmProjects/Teamspeak-IRC/test.py Scanning 1 ... traceback (most recent call final): File "C: / Users / Skins XXper / Picarc Projects / Times-APEC-IRC / Test Uses", Line 14, In Module & gt; Tn = telnetlib.Telnet (HOST [i], 23,3) File "C: \ Python27 \ lib \ telnetlib.py", line 211, __init__ in self.open (host, port, timeout) file "C: \ Python27 \ Lib \ telnetlib.py ", line 227, open self.sock = socket.create_connection (the host, port) timeout) in the file" C: \ Python 27 \ lib \ socket.py ", line 553, create_connection        

Div class = "post-text" itemprop = " Text ">

HOST for each character, you are trying to solve that character; This is due to the use of the loop in combination with your HOST indexing. For example, in the first iteration, you try to connect to the host from an IP. "1" - - which produces gaierror

To fix this, do not just try to connect with a specific index. HOST : HOST [i] Change from HOST to telnetlib.Telnet in the call:

  tn = telnetlib.Telnet (HOST, 23, 3)  

What are you trying to do with that loop, though, I am amazed.


Comments