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.
15 lines
482 B
15 lines
482 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)
|
|
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)) |