commit 84c51b3cfb44dc71e5b3c7cd5c01757adbb59be8 Author: Eric Date: Thu Jan 18 21:00:19 2024 +0100 EjercicioServidorUDPSantiyEric diff --git a/ServidorUPD.py b/ServidorUPD.py new file mode 100644 index 0000000..3e1e31f --- /dev/null +++ b/ServidorUPD.py @@ -0,0 +1,19 @@ +import socket + +HOST = '' +PORT = 3333 + +with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: + + s_addr = (HOST, PORT) + s.bind(s_addr) + #recibir + datos, addr = s.recvfrom(1024) #lĂ­nea bloqueante + print('recibidos {} bytes de {}'.format(len(datos), addr)) + print(datos) + mensaje_mayusculas = datos.upper() + + #enviar + if datos: + sent = s.sendto(mensaje_mayusculas, addr) + print('enviados {} bytes de vuelta a {}'.format(sent, addr)) \ No newline at end of file