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.

19 lines
460 B

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))

Powered by INFORMATICA.FP.EDU.ES.