You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
945 B

import socket
def cliente_udp():
cliente = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
direccion_servidor = ('localhost', 2000)
idioma_elegido = input("Seleccione el idioma (ingles, frances, italiano, portugues, japones o coreano): ")
while True:
opcion = input("Ingrese 'c' para cambiar de idioma, una palabra o '0' para salir: ")
if opcion == '0':
break
elif opcion == 'c':
idioma_elegido = input("Seleccione el nuevo idioma (ingles, frances, italiano, portugues, japones o coreano): ")
continue
mensaje = f"{opcion},{idioma_elegido}"
cliente.sendto(mensaje.encode('utf-8'), direccion_servidor)
datos, _ = cliente.recvfrom(1024)
respuesta = datos.decode('utf-8')
print(f"Respuesta del servidor: {respuesta}")
print("Conexión terminada.")
cliente.close()
if __name__ == "__main__":
cliente_udp()

Powered by INFORMATICA.FP.EDU.ES.