Я базовый/новый программист на языке python. Я пытаюсь создать чат-сервер, который подключается через Telnet. Мой код работает хорошо (я думаю), и он не позволит мне подключиться, когда я пытаюсь подключиться через cmd. кто-нибудь знает, почему эта ошибка может произойти, поскольку он говорит, что «соединение не удалось». Кстати, это код, который я использую;Python чат-сервер
import sys #imports system
import socket #imports socket features
from _thread import *
host = '' #sets host to your IP
port = 5555 #Connects to any port
s =socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try: #runs the connection
s.bind((host, port))
except socket.error as e:
print(str(e))
s.listen(5) #listens for a queue of 5
print ('Waiting for a connection...')
def threaded_client(conn): #each time someone makes a connection it will pass them through a threaded client
conn.send(str.encode('Welcome, type your info\n'))
while True: #giving a server output to all users
data =conn.recv(2048)
reply = 'Server Output: '+data.decode(uft-8)
if not data:
break
conn.sendall(str.encode(reply))
conn.close()
while True:
conn, addr = s.accept() #connecting to address and accepts
print ('Connected to: '+addr[0]+':'+str(addr[1])) #just some additional information that the user will see.
start_new_thread(threaded_client,(conn,))
Я использую cmd и набрав 'telnet localhost 5555' – chriscarter5789