使用tkinter
,当我尝试打开客户端时出现错误:
NameError:未定义全局名称“客户端”
Traceback(most recent call lost):
File "C:\Users\Gerardi\Desktop\graf2.py", line 21, in <module>
cliente2 = conectar()
File "C:\Users\Gerardi\Desktop\graf2.py", line 18, in conectar
cliente.connect(address)
File "C:\Python27\lib\socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
ocket.error: [Errno 10049] La direcci¾n solicitada no es vßlida en este context
def conectar():
cliente = socket.socket(2,1)
ip = cuadro_texto3.get("1.0", "1.end")
address = (ip, 5001)
cliente.connect(address)
return cliente
cliente2 = conectar()
def check_message(cliente):
while True:
try:
datos = cliente.recv(1000)
cuadro_texto2.insert("1.0", datos)
except socket.error:
break
if datos == "quit":
cliente.close()
server.close()
cliente.close()