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.

20 lines
448 B

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)
message = b'Saludos desde el cliente'
# 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))

Powered by Informatica FP.