diff --git a/ejer_alexa/alexaClient.py b/ejer_alexa/alexaClient.py new file mode 100644 index 0000000..55ed74f --- /dev/null +++ b/ejer_alexa/alexaClient.py @@ -0,0 +1,32 @@ +import socket + +HOST = '192.168.50.106' +PORT = 2000 + +with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: + s_addr = (HOST, PORT) + server_address = (s_addr) + # 1 para español, 2 para ingles, 3 para aleman + + while True: + idioma = input("Ingrese el idioma: ") + if idioma == "español": + message = b"1" + break + elif idioma == "ingles": + message = b"2" + break + elif idioma == "aleman": + message = b"3" + break + else: + print("Ingrese un idioma valido") + + # enviar + print('Enviando {}'.format(message)) + sent = s.sendto(message, server_address) + + # recibir + print('Esperando por la respuesta') + data, server = s.recvfrom(1024) # línea bloqueante + print('Recibido: {}'.format(data)) diff --git a/ejer_alexa/alexaServer.py b/ejer_alexa/alexaServer.py new file mode 100644 index 0000000..6b849f3 --- /dev/null +++ b/ejer_alexa/alexaServer.py @@ -0,0 +1,24 @@ +import socket +HOST = '' +PORT = 2000 +with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: + s_addr = (HOST, PORT) + s.bind(s_addr) + while True: + #recibir + datos, addr = s.recvfrom(1024) #línea bloqueante + print('recibidos {} bytes de {}'.format(len(datos), addr)) + print(datos) + #enviar + if datos: + + if datos == b"1": + s.sendto(b"hola", addr) + elif datos == b"2": + s.sendto(b"hello", addr) + + elif datos == b"3": + s.sendto(b"hallo", addr) + + else: + s.sendto(b"Lenguaje no reconocido", addr) \ No newline at end of file diff --git a/ejer_bucle/cliente.py b/ejer_bucle/cliente.py index b9873f1..508f6a9 100644 --- a/ejer_bucle/cliente.py +++ b/ejer_bucle/cliente.py @@ -1,6 +1,6 @@ import socket -HOST = '127.0.0.1' +HOST = '192.168.50.94' PORT = 2000 with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: