import socket HOST = '127.0.0.1' PORT = 2000 with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: s_addr = (HOST, PORT) server_address = (s_addr) cadena = input("Por favor, introduce una cadena: ") message = bytes(cadena, 'utf-8') # enviar print('Enviando {!r}'.format(message)) sent = s.sendto(message, server_address) # recibir print('Esperando por la respuesta') data, server = s.recvfrom(1024) #lĂ­nea bloqueante print('recibidos {!r}'.format(data))